PLEASE NOTE The title is supposed to be "Why is my script not working at all?"
I have this cash script that is in a part and the part is in workspace, The script basically is supposed to add 100 to the value on the "Cash" leaderstat. I am having trouble figuring out whats wrong with it and why it is not working...I have tried testing it on Studio and I also tested it on a roblox world but it is not working.. the output is empty and I can't seem to find the problem:
debounce = true
function Touch(part)
if debounce then
debounce = false
local h = part.Parent:FindFirstChild("Humaniod")
if h ~= nil then
local player = game.Players.GetPlayerFromCharacter(part.Parent)
if player then
player:WaitForChild("leaderstats")
player.leaderstats:WaitForChild("Cash")
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 100
end
end
debounce = true
end
end
script.Parent.Touched:connect(Touch)
If somebody can help me that would be awesome... :D thanks

1 comment
Thank you for the help I found out the problem in the end was: I needed to do :GetPlayerFromCharacter and I did .GetPlayerFromCharacter