Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
1
Answered by
MrMedian 160
6 years ago

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)
0
workspace[Player.Name] will error if the player's name is Part LOL User#19524 175 — 6y
0
yeah lol. just using the same coding style that the OP used so as not to confuse them MrMedian 160 — 6y
0
Ok, so I put this server code in the SSS: krustatiion -3 — 6y
Ad

Answer this question