Like, if the owner of the game their playing joins, how do I make their character go into their own team?
COMMUNITY QUESTION
What is a script to make an owner of a game spawn into a certain team?
2 answers
I hope this works for you but make sure you edit the variables and tables for your needs.If it doesn't work I'll fix it if there's any mistakes.
Owner={"Kozero"}--Name of owners
Color="Bright red"--edit to change the colour and make sure it's cap sensitive.
function onPlayerEntered(Plyr)
for i,v in pairs(Owner) do
if Plyr.Name ==v then
Plyr.TeamColor = BrickColor.new(Color)
end
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
Put this in a script under 'Workspace'. I'm not sure if that matters lol. Also if you want to understand it and not just copy and paste the script just ask
game.Players.PlayerAdded:connect(function(player)
if player.Name == "YourPlayerNameHere" then
local Team = Instance.new("Team", game.Teams)
Team.Name = "Whatever you'd like your team to be called"
Team.AutoAssignable = false
Team.AutoColorCharacters = false
Team.TeamColor = BrickColor.Red()
player.TeamColor = BrickColor.Red()--Player team color must be the same as the team color.
player.Neutral = false
end
end)
Make sure that your 'Teams' service is in the game. If it's not just go to 'Insert', 'Service', then 'Teams'.
This discussion is preserved as it was. New answers, comments, and votes are closed.
