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