Ive got a gear called Coolboy6153 and it should award a badge when i touch a brick with it.
local badgeID = 359826248
local badgeService = game:GetService("BadgeService")
function onTouched(part)
local playername = part.Parent.Parent.Parent.Name
local player = game.Players:FindFirstChild(playername)
if part.Parent.Name == "Coolboy6153" then
badgeService:AwardBadge(player.userId, badgeID)
end
end
script.Parent.Touched:connect(onTouched)
Error: Workspace..Torso.Script:7: attempted to index local 'player' (a nil value)

1 comment
Why is it part.Parent.Parent.Parent.Name?