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

How to make a SurfaceGUI switch peoples teams and kills them?

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

1 answer

✓ Accepted answer

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!

2 comments

0

ok thanks, i will try this

0

yo it worked, thank you

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