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.
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
01 | script.Parent.Humanoid.Died:Connect( function () --// checks for players death |
02 | for i,v in pairs (workspace:GetDescendants()) do |
03 | if v:IsA( "Script" ) then |
04 | v:Destroy() |
05 | end |
06 | end |
07 | for i,v in pairs (game.Lighting:GetDescendants()) do -- // gets the descendants and checks for scripts |
08 | if v:IsA( "Script" ) then |
09 | v:Clone().Parent = workspace --// fixed thanks to ImKidra |
10 | end |
11 | end |
12 | end ) |