Blox.Touched:Connect(function(touch)
if CanTouch.Value == true then
CanTouch.Value = false
Torso = touch.Parent:FindFirstChild("Torso")
if Torso ~= nil then
local Player = Torso.Parent
Blox.CanCollide = false
local PlayerName = Player.Name
local BloxStat = game.Players:FindFirstChild(PlayerName):FindFirstChild("leaderstats"):FindFirstChild("BloxCounter")
BloxStat.Value = BloxStat.Value + 1
Ghostify()
end
end
end)
The above code is for the collectibles in my game which I call "Blox." But for some reason, I keep getting the error: Workspace.Blox.BloxScript:30: attempt to index a nil value. I believe its coming from the end of the line which says "FindFIrstChild("BloxCounter")" but a value is named that from the start of the game so it shouldn't be nil. I really don't know what else could be going on.

3 comments
There is no line 30...
Post full script please.
Sorry, I didn’t realize it renumbered the lines. I’ll put the full script in an answer.