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?
function onTouched(hit) local Player = hit.Parent:findFirstChild("Humanoid") if (Player ~= nil) then game.Players:findFirstChild(Player.Parent.Name).leaderstats.Points.Value = game.Players:findFirstChild(Player.Parent.Name).leaderstats.Points.Value + 50000 end script.Parent.Touched:connect(onTouched)
I don't think you put "Name" I think you put something else, like your name. But tweak the first part a bit.