Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I made a game but it gives me this error- Touched is not a valid member of LocalScript -Any help?

Asked by 6 years ago
Edited 6 years ago
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?

2
This sould really be a server script. Chech the hierarchy of yous script, the parent should be the part. User#5423 17 — 6y
0
^ starmaq 1290 — 6y
0
Thanks its working now! admiral2001 36 — 6y

Answer this question