|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|