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

What is a script to make an owner of a game spawn into a certain team?

Asked by 10 years ago

Like, if the owner of the game their playing joins, how do I make their character go into their own team?

2 answers

Log in to vote
0
Answered by
Kozero 120
10 years ago

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)

Ad
Log in to vote
0
Answered by 10 years ago

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'.

Answer this question