Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

You might want to use a dictionary and call functions from the dictionary

1 answer

✓ Accepted answer

UserId not userId

3 comments

0

Now it says "UserID is not a valid member of Player"

0

Cos it's UserId not UserID

0

Now I feel like an idiot. Lol. Thanks for the help.

This discussion is preserved as it was. New answers, comments, and votes are closed.