Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix my script so it takes money away from player and saves when rejoin? [read desc]

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

0

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

1 answer

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.

1 comment

0

It Did not work Soban06! but thank you for trying.

This discussion is preserved as it was. New answers, comments, and votes are closed.