I have a local script:
script.Parent.Activated:Connect(function(p)
local cash = p.leaderstats.DepressionCoins.Value
if p >= 300 then
p = p - 300
end
end)
I thought p would mean the parent of whoever clicked it but it didn't. Can someone help?

14 comments
Thanks! It worked!
But I have an endless loop that gives you coins every 5 seconds so whenever it subtracts the currency it comes right back
If you need help with it, just ask me!
i just did
how do i stop it?
Maybe try using a boolvalue to stop the loop
Well no I want the loop to always be running, but whenever I subtract currency. The loop doesnt know that it has done that so it goes back to its original value.
game.Players.PlayerAdded:connect(function(p) local stats = Instance.new("IntValue", p) stats.Name = "leaderstats" local money = Instance.new("IntValue", stats) money.Name = "DepressionCoins" money.Value = 0 while true do wait(6) local newmoney = game.Players.LocalPlayer.leaderstats.DepressionCoins money.Value = money.Value + math.random(1,5) end end)
Can you edit that code into the answer?
its local though
its local though
OH, i get it now. You need it to work on the server now, right?
game.Players.LocalPlayer only works on a LocalScript tho, so i dont think the cash would change on everybody screens. use something like a remote event and then use plr something like that when the remote event gets fired idk i've never used remote events my friend taught me this i cant do the whole thing lol
Yeah, remotes are probably the way to go.