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

Team Change GUI TextButtons are only working in studio. Any Help?

So, I have a team change GUI and it only seems to work in roblox studio. I will give you guys full detail. I have more than 1 team spawns for each team(including the neutral team/choosing) and the script is a local script. I have one local script for each button(Red team and blue team). I figured this cant be a problem where I need FE because all it does is kill the player once they click the GUI to send them to the team. If i do need FE, what do I use? :FireClient()? Thank you all. Here is the local script in both textbuttons:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	player.TeamColor = BrickColor.new("Cyan")
	workspace[player.Name].Head:Destroy()
end)

1 answer

Yes, you will need FE. The way you should go about this is by using Remote:FireServer(NewTeamName) from a LocalScript to signal that the player wants to switch teams. Then, on the server do something like this

Remote.OnServerEvent:Connect(function(Player, NewTeamName)
	local newTeam = game.Teams:FindFirstChild(NewTeamName)
	if newTeam then
		Player.Team = newTeam
		workspace[Player.Name]:BreakJoints()
	end
end)

3 comments

0

workspace[Player.Name] will error if the player's name is Part LOL

0

yeah lol. just using the same coding style that the OP used so as not to confuse them

0

Ok, so I put this server code in the SSS:

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