I want it so when I press a surfaceGUI text button it switches teams of the player and kills the player
I tried something like this for the team switching
Game.Players.LocalPlayers.Teams = [“White”]
Does anyone know how to do it because I’m bad at coding
Hello! I believe I have a solution..
Insert a RemoteEvent
into ReplicatedStorage
. Call it ChangeTeam.
Insert a LocalScript into StarterGui and insert this:
local p = workspace["YourPartName"] local sg = Instance.new("SurfaceGui",game.Players.LocalPlayer.PlayerGui) sg.Face = Enum.NormalId.Front -- you can edit this to the correct pos sg.Adornee = p local tb = Instance.new("TextButton",sg) tb.Size = UDim2.new(1,0,1,0) tb.TextScaled = true tb.Text = "hello xd" -- edit this to what you want it to say tb.MouseButton1Click:Connect(function() game.ReplicatedStorage.ChangeTeam:FireServer() end)
Now insert a Script into ServerScriptService and insert this:
game.ReplicatedStorage.ChangeTeam.OnServerEvent:Connect(function(p) p.Team = game.Teams["ello B) 2"] -- you can edit this however u like p:LoadCharacter() -- this is basically resetting but its instant end)
Hope this helps!