EDIT : The main problem is that the cash.Value (local cash = stats:findFirstChild("Candy") --Get money) gives nil value. The problem with this is that I do have a leaderstat with the Candy as the currency.
What happens is my script passes by the print("Cat") and print("Dog") commands but then it does not pass print("Mow"). I do believe it has something to do with the cash value, correct me if i'm wrong. I have no errors when this happens. Any help?
local ting = 0 --debouncer function onClick(mouse) print("Hi") if ting == 0 then --debounce check ting = 1 --activate debounce check = mouse.Parent:FindFirstChild("Humanoid") --Find the human that touched the button print("Hillo") if check == nil then --If a human is found, then print("Hullo") local user = game.Players:GetPlayerFromCharacter(mouse.Parent) --get player from touching human print("Here") local stats = game.Workspace:findFirstChild("leaderstats") --Find moneyholder print("Hello") if stats ~= nil then --If moneyholder exists then print("Cat") local cash = stats:findFirstChild("Candy") --Get money print("Dog") cash.Value = cash.Value + 3 print("Mow") wait(0.3) --wait-time before button works again print("Wof") end end ting = 0 --remove debounce end end script.Parent.ClickDetector.MouseClick:connect(onClick)
Thanks.