Team spawn not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the player to spawn on Sea Green color spawn.

  2. What is the issue? Include screenshots / videos if possible!
    The player is not spawning on sea green spawn but instead in the Lobby’s spawn which is the default.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried changing the spawn team color, consult other devforum posts and rewrote my script many times.

Here is my script.

local player = game:GetService("Players").LocalPlayer

function Click()
	script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Sea green")
	script.Parent.Size = UDim2.new(0, 550,0, 300)
	wait(1)
    if player.Character and player.Character:FindFirstChild("Humanoid") then
		player.Character.Humanoid.Health = 0 -- Changes health to 0
	end
	script.Parent.Parent.Parent:Destroy() -- Delete the team change GUI
end

script.Parent.MouseButton1Down:connect(Click)

If you have any questions do not hesitate just reply to this message.
Thank you very much.

3 Likes

This is, a server script correct? (just asking)

1 Like

It is a local script in a TextButton

1 Like

Are you assigning the player to a team, using Player.Team?

I used

script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Sea green")

Is that okay? I do not know much because I am a beginner.

What you should be doing is setting the player Team to a specific team when the button is clicked Player.Team = (Team) (sorry if i am not explaining well)

This should help:

or this:

Also you make sure their aren’t any teams that are “neutral” or have the auto-assignable property

2 Likes

That is not my problem. The problem is that the player does not spawn on the correct spawn.
Here is a video

If it’s a local script it’s probably not changing the player’s team on the server. Try using a remote event with this.

5 Likes

The video is not loading, but as @RudraVII said you should be using a script somewhere on the server and setup a Remote connection (i miss interpreted your question, sorry) , but i also recommend you clean up your code a little and do something something like this for changing player teams:

----Server Script
local RemoteEvent = ----Where the remote event is
RemoteEvent.OnServerEvent:Connect(function(player)
if player then

player.TeamColor = ------TeamColor

     end
end)
	
-----Localscript


local gui = script.Parent
local player = game.players.LocalPlayer
local RemoteEvent = ---where the remote event is

function Click()
	
	script.Parent.Size = UDim2.new(0, 550,0, 300)
	wait(1)
    if player.Character and player.Character:FindFirstChild("Humanoid") then
		player.Character.Humanoid.Health = 0 -- Changes health to 0
	end
    RemoteEvent:FireServer()----No need to add the player parameter because its the first parameter given 
	script.Parent.Parent.Parent.Visible = false ----instead of destroying  the gui simply set the visible property to false
end

Gui.MouseButton1Down:connect(Click)
2 Likes

Thanks for the advice. I will arrange my scripts to not look messy.

4 Likes