Hello so I need help with this. its for a simulator, how do I make it take away money!! and save when the player leaves the game? Help would be appreciated.
local required_Money = 5000
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Money.Value >= required_Money then
if db then
db = false
script.Parent.Transparency = 0.8
script.Parent.CanCollide = false
wait(0.5)
script.Parent.Transparency = 0.4
script.Parent.CanCollide = true
db = true
end
else
print("1000 required Money")
end
end
end)

1 comment
hit.Parent would refer to game.Players by the way. Try doing hit.Character.Humanoid.