Help with team change commands!

Hi! I’ve been trying to achieve this goal for almost 1 day now, and I thought it was finally time to ask the Dev forum for help!

Issue:
I want people to be able to change teams when they type /usa or /japan in the chat…
Here is an example of what I have so far:
https://gyazo.com/3f29db2f92b0788832ac9da49b580795

As you see in the video, I can change to USA but I cannot change to japan…

I’ve placed my script inside of ServerScriptService, and this is the script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "/usa" or "/USA" or "/Usa" then
			plr.Team = game.Teams.USA
		elseif msg == "/japan" or "/Japan" or "/JAPAN" then
			plr.Team = game.Teams.Japan
		end
	end)
end)
´´´

Can someone please help?

Any output errors, or warnings?

Here, I also recoded it to allow any form of capitalization!

I fixed it, everytime you put a or you have to do msg == “blank” or msg == “blank1” then

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
        local message = string.lower(msg)
		if message == "/usa" then
			plr.Team = game.Teams.USA
		elseif message == "/japan" then
			plr.Team = game.Teams.Japan
		end
	end)
end)

Nope! I’ll try your other suggestion!

Did this work or not, If you didn’t realise I changed message to a string that is lowered so you dont have to add those or statements.

2 Likes

Is it possible there’s an error? Open your output and try again so we can see.

There isn’t an error. I believe Tyyuiss has already fixed the issue, I just haven’t had time to test it yet!

Thank you. This fixed the issue.

1 Like

Just so you know in the future I’m pretty sure you used or wrong since you didn’t specify the condition

1 Like