I tried something like this
local player = game.Players.LocalPlayer local Blue_Team = game.Teams.Blue_Team local Button = game.StarterGui.Team_GUI.Frame.Blue_Team local gui = script.Parent.Parent local Blue_Spawn = game.Workspace.Blue_Base.Blue_Spawn local function teleport() end local function onClicked(mouse) player.TeamColor = BrickColor.new("1010") player.Position = Vector3.new(115, 1.5, 138) gui:Remove() end script.Parent.MouseButton1Down:connect(onClicked)
Can't you make it so that once clicked the player will reset and just spawn to it's spawn location?
local player = game.Players.LocalPlayer MouseButton1Down:connect(function() player:WaitForChild("Character"):WaitForChild("Humanoid").Health = 0 end)
then it will auto-spawn in the spawn position. Accept answer and upvote if helped.
Hello,
I'm assuming you already have a SpawnLocation for the team you are trying to set in this script. You can do this in a simpler way, after you set the player's TeamColor, you can just use :LoadCharacter(). LoadCharacter is different than setting a player's health to 0 because LoadCharacter immediately respawns the player and doesn't make them wait for the 5 second delay. PS: You can also set a player's TeamColor by using, player.TeamColor = game.Teams["Team Name"].TeamColor.
Example of new code:
local player = game.Players.LocalPlayer local Blue_Team = game.Teams.Blue_Team local Button = game.StarterGui.Team_GUI.Frame.Blue_Team local gui = script.Parent.Parent local Blue_Spawn = game.Workspace.Blue_Base.Blue_Spawn local function teleport() end local function onClicked(mouse) player.TeamColor = BrickColor.new("1010") player:LoadCharacter() gui:Remove() end script.Parent.MouseButton1Down:connect(onClicked)
**If this worked for you please accept my answer. If you have any further questions, don't hesitate to ask. **