The player picks a team but it doesn't put them on the team spawn

Ok… So the team only spawn works if the Spawn is set to Neutral. But if Neutral = false then the player just spawns somewhere where theres no spawn.

Local Script
local TeamsFrame = script.Parent.Parent.Parent.Parent.TeamsFrame
local PlayerGUIYes = script.Parent.Parent.Parent.Parent.Parent:WaitForChild("PlayerGUIYes")
local Frameformore = script.Parent.Parent.Parent.Parent.Parent.PlayerGUIYes.Frameformore
local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Name

script.Parent.MouseButton1Click:Connect(function()
	game.Players[player].TeamColor = BrickColor.new("Bright green")
	game.Workspace[player].Humanoid.Health = 0
	
-- Tween
	Frameformore:TweenPosition(
		UDim2.new(0.755, 0, 0.911, 0),
		"In",
		"Back",
		1,
		false
	)
	
	TeamsFrame:TweenPosition(
		UDim2.new(-0.450, 0, -0.187, 0),
		"In",
		"Back",
		1,
		false
	)
	
end)

Can you show me the spawn properties?

Also, the problem might be because the teamcolor change only replicates locally and not to the server, which means that the server wont let the player spawn there.

Yup! I don’t know how to make it so that the server knows where spawn the player.
I’m going to look it up.

Screenshot 2021-11-28 145545

Screenshot 2021-11-28 145614

Just change the LocalScript to a ServerScript, and change that script to this:

local TeamsFrame = script.Parent.Parent.Parent.Parent.TeamsFrame
local PlayerGUIYes = script.Parent.Parent.Parent.Parent.Parent:WaitForChild("PlayerGUIYes")
local Frameformore = script.Parent.Parent.Parent.Parent.Parent.PlayerGUIYes.Frameformore
local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Name

script.Parent.MouseButton1Click:Connect(function()
	local TweenOnClient = Instance.new("RemoteEvent")
	TweenOnClient.Name = "TweenEvent"
	TweenOnClient.Parent = script:WaitForChild("LocalScript")
	TweenOnClient:FireClient(player)
	TweenOnClient:Destroy()
	game.Players[player].TeamColor = BrickColor.new("Bright green")
	game.Workspace[player].Humanoid.Health = 0
end)

Place a LocalScript named “LocalScript” inside of the above script:

script.ChildAdded:Connect(function(Child)
	if Child:IsA("RemoteEvent") then
		if Child.Name == "TweenEvent" then
			local Connection
			Connection = Child.OnClientEvent:Connect(function()
				local TeamsFrame = script.Parent.Parent.Parent.Parent.Parent.TeamsFrame
				local PlayerGUIYes = script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("PlayerGUIYes")
				local Frameformore = script.Parent.Parent.Parent.Parent.Parent.Parent.PlayerGUIYes.Frameformore
				-- Tween
				Frameformore:TweenPosition(
					UDim2.new(0.755, 0, 0.911, 0),
					"In",
					"Back",
					1,
					false
				)

				TeamsFrame:TweenPosition(
					UDim2.new(-0.450, 0, -0.187, 0),
					"In",
					"Back",
					1,
					false
				)
				Connection:Disconnect()
			end)
		end
	end
end)

Note: I’m sure there are better ways, but I’m kinda in a rush right now; I’m not even sure if this will work.

1 Like
local Player = script:FindFirstAncestorWhichIsA("Player")
local Character = Player.Character or Player.CharacterAdded:Wait()
local PlayerGui = Player:WaitForChild("PlayerGui")
local PlayerGUIYes = PlayerGui:FindFirstDescendant("PlayerGUIYes")
local Frameformore = PlayerGUIYes:FindFirstChild("Frameformore")
local TeamsFrame = PlayerGui:FindFirstDescendant("TeamsFrame")
local Button = script.Parent

Button.MouseButton1Click:Connect(function()
	Player.TeamColor = BrickColor.new("Bright green")
	Character:BreakJoints()
	
	Frameformore:TweenPosition(
		UDim2.new(0.755, 0, 0.911, 0),
		"In",
		"Back",
		1,
		false
	)

	TeamsFrame:TweenPosition(
		UDim2.new(-0.450, 0, -0.187, 0),
		"In",
		"Back",
		1,
		false
	)
end)

Possibly this although the original references are incredibly awkward.