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

Variable inside scripts reset when the humanoid dies?

Asked by 5 years ago
local player = game.Players.LocalPlayer

local Character = player.Character

if Money == nil then

Money = 50

end

local hum = Character:WaitForChild("Humanoid")





hum.Died:Connect(function()

if Money > 10 then

local Drop = math.random(5, 15)

print(Drop)

Money = Money - Drop

print(Money)

end

end)



while wait(1) do

print(Money)

end

The script works until the humanoid dies, then the money resets to 50. How would I make it so it stays on the value it was left on?

0
U need a wait(6) right under the hum.Died DEVLogos 8 — 5y
0
Is this script in the StarterCharacterScripts by any chance? Ankur_007 290 — 5y

Answer this question