Basically I want to click on a model that'll then dissapear and give you money yet I get the error saying taht they're trying to attempt the field "leaderstats" a nil value, here is the script
- [ ]
function OnClick()
local player = game.Players:GetPlayers()
for i=1,#player do
if (player[i]:FindFirstChild("leaderstats") ~= nil) then
local clicks = player[i].leaderstats.Money
if (clicks ~= nil) then
player.leaderstats.Money.Value = player.leaderstats.Money.Value +
250
script.Parent.Box.CanCollide = false
script.Parent.Box.Transparency = 1
script.Parent.TV3.CanCollide = false --Change COUCH to the name
of your model!
script.Parent.TV3.Transparency = 1 -- same here
wait(60) -- Change this to the amount of time you want until it
respawns (can be any number)
script.Parent.Box.CanCollide = true
script.Parent.Box.Transparency = 1
script.Parent.TV3.CanCollide = true -- change COUCH to the name
of your model !
script.Parent.TV3.Transparency = 0 -- same here
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(OnClick)

3 comments
line 26, "respawns" is supposed to stay with the green, isn't it? this may be stupid, but try deleting the green text in lines 25-26 just in case any of it is accidentally code and not green
^^ Going with this idea too. I would say it is best to remove all the comments and try again.
Nope, wasn't the issue :'(