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

Cash giver resets my cash amount?

Asked by
MexheCo 46
5 years ago
Edited 5 years ago

[EDIT] It is now adding the cash by 100. Say I have 17 dollars, and I click the ATM. I now have 100. If I were to spend all the money, and then click the ATM, I would have 200.

I have an ATM that, when clicked, gives the player 100 cash. However, it does not take the cash you already have and add 100 to it. It simply resets the player's cash, and then gives them 100 cash.

Why is this happening? I want 100 cash to be added to the player's funds that they have already.

Code:

clickDetector = script.Parent.ClickDetector
isHackable = script.isHackable
text = script.Parent.TextPart.SurfaceGui.TextLabel
cashSound = script.CashSound
startSound = script.Startup

isHackable = true

local function onMouseClick(player)

    if isHackable == true then
        cashSound:Play()
    player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 100
text.Text = "Rebooting..."
isHackable = false
wait(30)
startSound:Play()
isHackable = true
text.Text = "Hackable!"

    else
        print("Money Cooling Down")
    end

    end
clickDetector.MouseClick:connect(onMouseClick)

Leaderstats:

game.Players.ChildAdded:connect(function(player)
local stats = Instance.new("Model",player)
stats.Name="leaderstats"
local Cash = Instance.new("IntValue",stats)
Cash.Name="Cash"
Cash.Value=0 -- Change Your Starting Money
end)
0
You are using a Server Script? yHasteeD 1819 — 5y
0
The script is inside of an ATM model. It's not a local script. MexheCo 46 — 5y
0
Can you show us your leaderstats script? DinozCreates 1070 — 5y
0
Leaderstats in description MexheCo 46 — 5y
0
Why do you use ChildAdded instead of PlayerAdded, also :connect is deprecated, try to remember to have an uppercase c cmgtotalyawesome 1418 — 5y

Answer this question