What is wrong with my script?
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?
03 | function onClick(mouse) |
07 | check = mouse.Parent:FindFirstChild( "Humanoid" ) |
13 | local user = game.Players:GetPlayerFromCharacter(mouse.Parent) |
15 | local stats = game.Workspace:findFirstChild( "leaderstats" ) |
20 | local cash = stats:findFirstChild( "Candy" ) |
22 | cash.Value = cash.Value + 3 |
35 | script.Parent.ClickDetector.MouseClick:connect(onClick) |
Thanks.