Hey, I’m trying to make a team changer GUI that changes the players team then respawns them. But the respawn part isn’t working; this is the script I’m using right now.
I think Player:LoadCharacter() only works in server scripts. You will have to either use a remote or set their health to 0 manually(Player.Character.Humanoid.Health = 0)
You can’t change a player’s team from a local script as it won’t reflect to the entire server. To do this you’ll need a “RemoteEvent” instance which allows for the local script (which handles the Gui button click) to communicate with the server script (which will handle changing the player’s team).
--LOCAL SCRIPT--
local Storage = game:GetService("ReplicatedStorage")
local RE = Storage:WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
RE:FireServer()
end)
--SERVER SCRIPT--
local Storage = game:GetService("ReplicatedStorage")
local RE = Storage:WaitForChild("RemoteEvent")
RE.OnServerEvent:Connect(function(Player)
Player.TeamColor = BrickColor.new("Steel blue")
Player:LoadCharacter()
end)