here is my script its for whenever someone touches a brick it'll reward the player with 5000 points but theres a error with the code heres the script
local Player = hit.Name -- Error in script...
function onTouched(hit)
game.Players.Player.leaderstats.Points.Value = game.Players.Player.leaderstats.Points.Value + 50000
end
script.Parent.Touched:connect(onTouched)
why is
local Player = hit.Name
an error?

1 comment
It's an error because you can only use "hit" inside the function. You're trying to find something that might not yet exist because the event hasn't been activated yet (Something hasn't touched the part yet).