Help With Teams

I can’t figure out what is wrong with this script, can anyone help? (I’m new to scripting)
I’m making a script that changes the team and resets the character if they are in a specific private server.
I’ve been searching forms for like an hour and have yet to find answers/different scripts to use.

if game.VIPServerOwnerId ~= 350627172 then
end
local team = "Enter"
game.Players.PlayerAdded:connect(function (newPlayer)
	newPlayer.TeamColor = BrickColor.new(game.Teams:FindFirstChild(team).TeamColor)
	if newPlayer.Character then
		newPlayer.Character.Humanoid.Health = 0
	end
end)
1 Like

Why such a specific vip server?

1 Like

Its for a specific group training and I want to make it so it only works in one specific private server

I’m pretty sure it works with both

You put “TeamCoor” im pretty sure you meant “TeamColor”

1 Like

yeah i tried that, this is from the source code i got @Nube762

Can you try adding prints so we now that it’s either not running or messes up at a certain part.

Also is there such thing as VIPServerOwnerId or it’s PrivateServerOwnerId?

local VIPServerOwnerId = 350627172
local team = "Enter"

if game.PrivateServerId ~= "" and game.PrivateServerOwnerId ~= 0 then
    game:GetService("Players").PlayerAdded:Connect(function(newPlayer)
       if newPlayer.UserId == VIPServerOwnerId then 
       newPlayer.TeamColor = BrickColor.new(game.Teams:FindFirstChild(team).TeamColor)
    	if newPlayer.Character or newPlayer.CharacterAdded:Wait() then
    		newPlayer.Character.Humanoid.Health = 0
    	end
    end)

oh ok @Xx_FROSTBITExX ill try it

also yes there is a VIPServerOwnerId as far as i know

oop nvm you were right the script i was using (VIPServerOwnerId) was outdated

unfortunately, I was unable to check the print because the script does not start unless its a private server

does anyone know any scripts to change all people’s team, I could just link it up with the info I already have? @Xx_FROSTBITExX

Developer forum isn’t really for asking for scripts like that, I can just say that you could loop between all the players & then change their team one by one and reset them in the same loop. You can actually get that idea & script it on your own, by using different functions Roblox API offers to you

James said it all,
The devforum isn’t a place to ask scripts. Keep that in mind. Also it would be best if you kept all your replies in a single post, rather then creating multiple replies and reply to a specific person.

You can use a loop to iterate through all players, change their teams and reset.

Here’s a small snippet:

local Teams = game:GetService("Teams")

for i, player in pairs(game:GetService("Players"):GetPlayers()) do -- For loop
	if player.Team then -- If player is in a team 
		player.TeamColor = BrickColor.new("Black") -- Change team colour
		player.Team = Teams["Team1"] -- Change Name of team
	end
end

oh sorry, I did not mean to come off that way and I’ve never used devform before so thank you for the help. I was just wondering what variable that changes a persons team.