Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When dead reset scripts in Workspace?

Asked by 4 years ago

Hello everybody,

I'd like to know if it's possible to reset my scripts write in the Workspace when the Character dies. For example, i change the color and material of a button when i click on it but after the Character dies, it's still changed. My goal is to reset the button to the original one. I tried to search on forum and Web but can't find anything about it.

I'd like to know if it exists a way to reset my scripts (one-by-one? or all at the same time?) Also, the game has many spawns (like a obby).

Thank you in advance for your help.

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

If you want to reset workspace scripts use this:

  • use a Server Script

  • place it in Starter Character Scripts

  • clone all scripts into lighting

  • put this code into the server script




script.Parent.Humanoid.Died:Connect(function() --// checks for players death for i,v in pairs(workspace:GetDescendants()) do if v:IsA("Script") then v:Destroy() end end for i,v in pairs(game.Lighting:GetDescendants()) do -- // gets the descendants and checks for scripts if v:IsA("Script") then v:Clone().Parent = workspace --// fixed thanks to ImKidra end end end)
0
idk but maybe v:Clone().Parent? so it happens everytime he resets i think imKirda 4491 — 4y
0
My bad i rushed it yea. GoreDemons 215 — 4y
0
Thank you. KevinTito1378 6 — 4y
0
Badly, i probably made mistake (i'm new on learning LUA): i create Script in Starter Character Scripts (can't find Server Script) and copy/paste scripts from Workspace but the reset doesn't work on it. KevinTito1378 6 — 4y
Ad

Answer this question