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

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

Asked by
zomspi 541 Moderation Voter
4 years ago

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)




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 doggybite1 100 — 4y

1 answer

Log in to vote
0
Answered by
zomspi 541 Moderation Voter
4 years ago

@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)
Ad

Answer this question