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

How do I make this script save in backpack even after resetting?

Asked by 4 years ago
Edited 4 years ago

I have a script where it removes a previous script and replaces it with a new one but I can't figure out how to make it so the new one saves after resetting.

Here is the script:

local re = game.ReplicatedStorage.Green

re.OnServerEvent:Connect(function(player)
    for i, v in pairs(game.Players:GetChildren()) do
        v.Backpack.BeatSyncs:ClearAllChildren() 
    end
wait(0.1)
    for i, v in pairs(game.Players:GetChildren()) do
        local clubcolor= game.ServerStorage.BeatSyncClientGreen:Clone()
        clubcolor.Parent = v.Backpack.BeatSyncs
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

A way you can do this is by having a script watching the players and if they die What you need to do is make the script you want in their back pack placed into the death watch script as its child then disable it and have the death watch script watch on the players death copy the script and then move the copy to the backpack and then enable it by turning disabled = false

Sorry there is no code wasn't too clear on how yours was set up but at least here is what would be needed for the death watch script

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        repeat wait() until character.Humanoid
        character.Humanoid.Died:connect(function()

        end)
    end)
end)

0
"repeat wait() until character.Humanoid" really? This will still error if the humanoid doesn't exist, and don't reinvent the wheel, just use :WaitForChild(), and :connect is deprecated infavour of :Connect User#24403 69 — 4y
Ad

Answer this question