generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Can anyone help with cloning an item in a script?

Previous Thread :: Next Thread 
robloxguy505123 is not online. robloxguy505123
Joined: 30 Dec 2011
Total Posts: 3736
16 Aug 2015 12:49 PM
I have a script that adds "Scrap Metal" to the player's leaderboard when they touch a part. The script works fine, however, it destroys the parent to prevent players continuing to touch the object to keep getting more "Scrap Metal". I want it to respawn/clone after 300 seconds. Can anyone help with this?

The script in question is this:

amnt = 5
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Scrap Metal")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:Destroy()
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
tyzone is not online. tyzone
Joined: 16 Aug 2008
Total Posts: 1726
16 Aug 2015 12:51 PM
You could have a piece of scrap metal in the ReplicatedStorage (scripts don't run there), and then create a script somewhere else that clones the scrap metal every 300 seconds and gives it a random position somewhere on your map each time?


eww no pink shaggy
Report Abuse
robloxguy505123 is not online. robloxguy505123
Joined: 30 Dec 2011
Total Posts: 3736
16 Aug 2015 12:54 PM
@tyzone-

I was thinking of doing something like that, and it would work really well. But, I have a very limited knowledge of scripting and I'd have trouble doing something like that.

Thanks for the suggestion though!
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
16 Aug 2015 12:56 PM
You could add a debounce to the function, making the scrap invis and uncancollided while the debounce is up
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image