Here is my script. It is a simple code that on click, the object will be removed and the player's leaderstats ("Money") will be increased. I can't find anything wrong with it, but some of you might. The error is "Workspace.Handle.ClickDetector.Script:6: attempt to index a nil value" The teapot disappears, BUT the leaderstats remain the same.
local teapot = script.Parent.Parent script.Parent.MouseClick:connect(function(playerWhoClicked) teapot.Transparency = 1 teapot.CanCollide = false playerWhoClicked:FindFirstChild("Money").Value = playerWhoClicked:FindFirstChild("Money").Value + 125 end)
The problem is that the 'Money' leaderstat is inside of leaderstats, not the player..
player>leaderstats>Money
Do this;
local teapot = script.Parent.Parent script.Parent.MouseClick:connect(function(plr) teapot.Transparency = 1 teapot.CanCollide = false local money = plr.leaderstats:FindFirstChild('Money') if money then --Check if it's there. money.Value = money.Value + 125 end end