The team switch works but when u switch the team u cant get the clothes even tho u should here is the script error and some ss:
server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Handler = ReplicatedStorage.Handler
local Teams = game:GetService("Teams")
local function equipClothes(Character, Team)
if Team == "VIP" then
Character.Shirt:Destroy()
Character.Pants:Destroy()
local shirt = ReplicatedStorage.Prisoner.Shirt:Clone()
shirt.Parent = Character
local pants = ReplicatedStorage.Prisoner.Pants:Clone()
shirt.Parent = Character
elseif Team == "Players" then
Character.Shirt:Destroy()
Character.Pants:Destroy()
local shirt = ReplicatedStorage.Players.Shirt:Clone()
shirt.Parent = Character
local pants = ReplicatedStorage.Players.Pants:Clone()
shirt.Parent = Character
end
end
Players.PlayerAdded:Connect(function(Player)
Players.CharacterAdded:Connect(function(Character)
if Player.Team.Name == "VIP" then
repeat task.wait() until Character.shirt and Character.pants
equipClothes(Character, "VIP")
elseif Player.Team.Name == "Players" then
repeat task.wait() until Character.shirt and Character.pants
equipClothes(Character, "Players")
end
end)
end)
Handler.OnServerEvent:Connect(function(Player, Team)
Player.Team = Teams[Team]
equipClothes(Player.Character, Teams[Team])
Player:LoadCharacter()
end)
error:
CharacterAdded is not a valid member of Players "Players"
ss from the studio: