script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) local leaderstats = player:WaitForChild("leaderstats") local hearts = leaderstats.Hearts hearts.Value = hearts.Value + 1 script.Parent:Destroy() end end)
it works but it keeps giving me an error:
Workspace.heart.collect:4: attempt to index local 'player' (a nil value)
can anybody fix my script please?
i appreciate it.