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)
After line 9 (i.e. after you said db = false), you should say:
player.leaderstats.Money.Value - required_money
OR
player.leaderstats.Money.Value = player.leaderstats.Money.Value - required_money
Check which one of these works and let me know.