Hello Developers! I am working on a script that puts me and the founder on a special founder team when we join. Everything works great. However, when I test using the local server test feature, the player joins the founder team when they should not be getting past the if statement. Please respond with feedback so I can fix this. Thanks!
-- Caden
local minigun = game.ServerStorage:WaitForChild("Minigun")
local F3X = game.ServerStorage:WaitForChild("F3X")
game.Players.PlayerAdded:Connect(function(player)
if game.Teams:FindFirstChild("Founder") == nil then
if player.UserId == 221567745 or 286092004 then
local founderTeam = Instance.new("Team")
founderTeam.Parent = game.Teams
minigun:Clone().Parent = founderTeam
F3X:Clone().Parent = founderTeam
founderTeam.Name = "Founder"
founderTeam.AutoAssignable = false
founderTeam.TeamColor = BrickColor.new("Toothpaste")
player.Team = founderTeam
end
else
if player.UserId == 221567745 or player.UserId == 286092004 then
player.Team = game.Teams.Founder
end
end
end)
You’re checking if the UserId is equal to the first value and simply checking if the second number is valid. Change that line to if player.UserId == 221567745 or player.UserId == 286092004 then so that it checks both IDs in relation to the player.
I know that the guy above probably already solved your problem but I also solved it, organized your code and added easier customization:
--//Services
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Teams = game:GetService("Teams")
--//Variables
local minigun = ServerStorage:WaitForChild("Minigun")
local F3X = ServerStorage:WaitForChild("F3X")
--//Tables
local Founders = { --//Insert founder ids
221567745,
286092004,
}
--//Functions
Players.PlayerAdded:Connect(function(player)
if table.find(Founders, player.UserId) then
if not Teams:FindFirstChild("Founder") then
local founderTeam = Instance.new("Team")
founderTeam.Name = "Founder"
founderTeam.AutoAssignable = false
founderTeam.TeamColor = BrickColor.new("Toothpaste")
founderTeam.Parent = Teams
minigun:Clone().Parent = founderTeam
F3X:Clone().Parent = founderTeam
player.Team = founderTeam
else
player.Team = Teams.Founder
end
end
end)