So I’ve created a GUI that allows you to select your team. After you’ve selected your team, it assigns you to your selected team and respawns you. However, instead of you spawning at your new team’s spawn, you spawn at the pending spawn. I’ve tried fixing it a couple of times by myself, but it still doesn’t spawn you at your team’s spawn. This is my script
local player = game.Players.LocalPlayer
local team = game.Teams["Example Team"]
local spawnplace = game.Workspace.TeamSpawns.ExampleTeamSpawn
script.Parent.MouseButton1Click:Connect(function()
player.Team = team
script.Parent.Parent.Parent.Visible = false
player.Character.Humanoid.Health = 0
player.RespawnLocation = spawnplace
end)
Also, sorry if I’m using devforum wrong in a way. This is my first time posting.
local player = game.Players.LocalPlayer
local team = game.Teams["Example Team"]
local spawnplace = game.Workspace.TeamSpawns.ExampleTeamSpawn.Position --This must be a part
script.Parent.MouseButton1Click:Connect(function()
player.Team = team
script.Parent.Parent.Parent.Visible = false
player.Character.Humanoid.Health = 0
player.RespawnLocation = spawnplace
end)
Thank you for responding! However, it sadly still won’t work. I’ve made sure the script was a LocalScript, and changed the spawnplace into part, but it won’t work. Thank you for trying to help
Oops, sorry about that but did you tried this out?
I don’t really know what does it works but you probably need to be on a team same colour as the TeamColor i said above. I think it would be helpful for you.
script.Parent.MouseButton1Click:Connect(function(player)
-- fire a RemoteEvent here linked to a script to change the player's team
script.Parent.Parent.Parent.Visible = false -- this must stay in this LocalScript
player.Character.Humanoid.Health = 0 -- put this in the script linked by the RemoteEvent
player.RespawnLocation = spawnplace -- put this in the script too
end)
I’m pretty sure a player’s team property does replicate from the server to the client (it obviously won’t replicate the other way but the documentation’s information is slightly outdated).