Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My 'Change Team On Player Added' Script Doesn't Work?

No errors are show, I am completely stuck to what is wrong?

game.Players.PlayerAdded:Connect(function(plr)
	if game.Teams:FindFirstChild("Customer") and game.Teams:FindFirstChild("Manager") then
    local leaderstatsA = plr:WaitForChild("leaderstatsA")
    if leaderstatsA:WaitForChild("Customer").Value == true and leaderstatsA:WaitForChild("Manager").Value == false
     then
print("idk")
        plr.Team = game.Teams.Customer
        
    end
    if leaderstatsA:WaitForChild("Manager").Value == true and leaderstatsA:WaitForChild("Customer").Value == false
        then
        plr.Team = game.Teams.Manager
        
        end
end
end)




1 comment

0

Not sure if this is the issue without seeing the rest of your code, but if the value of manager and customer are the same, then plr.Team will never be assigned

1 answer

@doggybite1 if it helps the only other script in the game is this one

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("Customer")
local ds2 = datastore:GetDataStore("Manager")

game.Players.PlayerAdded:connect(function(plr)
 local folder = Instance.new("Folder", plr)
 folder.Name = "leaderstatsA"
 local Customer = Instance.new("BoolValue", folder)
 Customer.Name = "Customer"
 local Manager = Instance.new("BoolValue", folder)
 Manager.Name = "Manager"
 
 Customer.Value = ds1:GetAsync(plr.UserId) or true
 ds1:SetAsync(plr.UserId, Customer.Value)
 
 Manager.Value = ds2:GetAsync(plr.UserId) or false
 ds2:SetAsync(plr.UserId, Manager.Value)
 
 Customer.Changed:connect(function()
  ds1:SetAsync(plr.UserId, Customer.Value)
 end)
 
 Manager.Changed:connect(function()
  ds2:SetAsync(plr.UserId, Manager.Value)
 end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.