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

help with finding cash value in player?

Asked by 10 years ago

ok so im learning to make tycoon type things now and the only part i am stuck on is the buy buttons, how would i find if the person touching it has the cash or not?

um i dont know about this tags thing, i never formally learned Lua so i dont know what most of them mean..

1 answer

Log in to vote
0
Answered by
Aespect 25
10 years ago

The following script will check to see if the player has cash above 300. If he does, then it will print "Success" in the output:

local RequiredCash = 300

script.Parent.Touched:connect(function(h)
    if h.Parent:FindFirstChild("Humanoid") then
        local p = game.Players:FindFirstChild(h.Parent.Name)
        if p.leaderstats.Cash.Value > RequiredCash then
            print("Success")
        end
    end
end)
0
thanks chimmihc -2 — 10y
Ad

Answer this question