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

Why am I getting this error for my custom commands script?

Asked by 5 years ago

When I tested out this script for custom commands I got an error, the error is: "userID is not a valid member of Player". How would I fix this and make the commands work?

function onChatted(msg, speaker)
    local source = string.lower(speaker.Name)
    msg = string.lower(msg)
    if msg == "!respawn" then
        speaker:LoadCharacter()
    elseif msg == "!sparkles" then
        Instance.new("Sparkles", speaker.Character.HumanoidRootPart)
    elseif msg == "!ff" then
        Instance.new("ForceField", speaker.Character)
    elseif msg == "!run" then
        speaker.Character.Humanoid.WalkSpeed = 25
    elseif msg == "!walk" then
        speaker.Character.Humanoid.WalkSpeed = 16
    elseif msg == "!sit" then
        speaker.Character.Humanoid.Sit = true
    end
end

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userID, 5087872) then
    player.Chatted:connect(function(msg) onChatted(msg, player) end)
    end
end)
0
You might want to use a dictionary and call functions from the dictionary EpicMetatableMoment 1444 — 5y

1 answer

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
5 years ago

UserId not userId

0
Now it says "UserID is not a valid member of Player" TypicallyPacific 61 — 5y
0
Cos it's UserId not UserID Elixcore 1337 — 5y
0
Now I feel like an idiot. Lol. Thanks for the help. TypicallyPacific 61 — 5y
Ad

Answer this question