local db = true
local playerstats = game.Players:FindFirstChild("leaderstats")
script.Parent.ClickDetector.MouseClick:connect(function(onClicked)
if db == true then
db = false
script.Parent.Transparency = 1
playerstats.Robux.Value = playerstats.Robux.Value + 10
script.Parent.Sound:Play()
script.Parent.ParticleEmitter.Enabled = false
wait(10)
db = true
script.Parent.Transparency = 0
script.Parent.ParticleEmitter.Enabled = true
end
end)
I tested this script and it said this in the output:
"16:41:40.424 - Workspace.Soda Can.CollectScript:10: attempt to index a nil value"
I've tried multiple things to fix such as changing up the variable, and nothing seems to work. Any help would be greatly appreciated.

2 comments
You Are Looking In Players For 'playerstats' which is not Players
i just named the variable that, does it really matter?