print("Badge Awarder Loaded. BadgeID: " .. script.BadgeID.Value)
function OnTouch(part)
if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
local p = game.Players:GetPlayerFromCharacter(part.Parent)
if (p ~= nil) then
print("Awarding BadgeID: " ..script.BadgeID.Value .. " to UserID: " .. p.userId)
local b = game:GetService("BadgeService")
b:AwardBadge(p.userId, script.BadgeID.Value)
end
end
end
script.Parent.Touched:connect(OnTouch)
I have this script in my game but it gives me an error
Touched is not a valid member of LocalScript
Any idea how to fix it?

3 comments
This sould really be a server script. Chech the hierarchy of yous script, the parent should be the part.
^
Thanks its working now!