Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

team spawns dont work after changing teams with a local script, fix?

my script is a local script inside a text box, i enter my name into the textbox, and it kills me, but the team spawns break and i dont spawn at the cage spawn, and yes, i do have all of the spawns set to the right colors.

code here:

local TextBox = script.Parent

TextBox.FocusLost:Connect(function()
	if game.Players[TextBox.Text] then
		local player = game.Players[TextBox.Text]
		local character = player.Character or player.CharacterAdded
		print(TextBox.Text.." Player found")

		TextBox.Parent.Players.MouseButton1Click:Connect(function()

			
			character:FindFirstChild("Humanoid").Health = 0
			

		end)


		TextBox.Parent.Cage.MouseButton1Click:Connect(function()


			character:FindFirstChild("Humanoid").Health = 0

		end)
		
	else
		print(TextBox.Text.." Player not found")
	end
end)

1 answer

Try this (can not test im on phone rn)

You will need a remote event in replicated storage named: RequestTeamChange

Local script:

local TextBox = script.Parent

TextBox.FocusLost:Connect(function()
    if game.Players[TextBox.Text] then
        local player = game.Players[TextBox.Text]
        local character = player.Character or player.CharacterAdded
        print(TextBox.Text.." Player found")

        TextBox.Parent.Players.MouseButton1Click:Connect(function()


            character:FindFirstChild("Humanoid").Health = 0

	game.ReplicatedStorage.RequestTeamChange:FireServer('Cage',Player)


        end)


        TextBox.Parent.Cage.MouseButton1Click:Connect(function()


            character:FindFirstChild("Humanoid").Health = 0

	game.ReplicatedStorage.RequestTeamChange:FireServer('Players',Player)

        end)

    else
        print(TextBox.Text.." Player not found")
    end
end)

Server Script:

game.ReplicatedStorage.RequestTeamChange.OnServerEvent:Connect(function(c,t,p)
local s,e=pcall(function()
p.Team=game.Teams[t]
end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.