Hello. I made a script where you can choose what team you want to be on. There is team Red and Blue. Well, I tested my script, and when a player dies, it’ll change they’re team. For example if I was on team red and I died, then respawned, I’d be on team blue. Which that is a problem. How can I fix that?
Client Script:
local Button1 = script.Parent.Blue
local Button2 = script.Parent.Red
local Remote = game.ReplicatedStorage.changeTeam
local Color1 = "Really blue"
local Color2 = "Really red"
local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
repeat wait() until plr.Character or plr.CharacterAdded:Wait()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = workspace.cameraPart.CFrame
Button1.MouseButton1Click:Connect(function()
Remote:FireServer(BrickColor.new(Color2))
game.Lighting.BlurShop.Enabled = false
wait(.02)
cam.CameraType = Enum.CameraType.Custom
script.Parent.Parent.Enabled = false
game.ReplicatedStorage.OverheadTextTeamChanger:FireServer()
local health = plr.PlayerGui.PlayScreen:FindFirstChild("Health")
plr.Character:WaitForChild("Humanoid").MaxHealth = health.Value
plr.Character:WaitForChild("Humanoid").Health = health.Value
script.Parent.Visible = false
script.Parent.Parent.Enabled = false
for i, v in pairs(script.Parent.Parent.First:GetChildren()) do
if v:IsA("ImageButton") or v:IsA("TextButton") or v:IsA("TextLabel") then
v.Visible = true
end
end
end)
Button2.MouseButton1Click:Connect(function()
Remote:FireServer(BrickColor.new(Color2))
game.Lighting.BlurShop.Enabled = false
wait(.02)
cam.CameraType = Enum.CameraType.Custom
script.Parent.Parent.Enabled = false
game.ReplicatedStorage.OverheadTextTeamChanger:FireServer()
local health = plr.PlayerGui.PlayScreen:FindFirstChild("Health")
plr.Character:WaitForChild("Humanoid").MaxHealth = health.Value
plr.Character:WaitForChild("Humanoid").Health = health.Value
script.Parent.Visible = false
script.Parent.Parent.Enabled = false
for i, v in pairs(script.Parent.Parent.First:GetChildren()) do
if v:IsA("ImageButton") or v:IsA("TextButton") or v:IsA("TextLabel") then
v.Visible = true
end
end
end)
Server Script:
game.ReplicatedStorage.changeTeam.OnServerEvent:Connect(function(player, teamColor)
player.TeamColor = teamColor
player:LoadCharacter()
game.Lighting.BlurShop.Enabled = false
-- player.PlayerGui.PlayScreen.Enabled = false
-- player.PlayerGui.Ammo.Enabled = true
player.PlayerGui.Health.Enabled = true
player.PlayerGui.HotBarGUI.Enabled = true
player.PlayerGui.PlayerInfo.Enabled = true
player.PlayerGui.Stamina.Enabled = true
player.CameraMode = Enum.CameraMode.LockFirstPerson
end)
Help soon,