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

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

Asked by 1 year ago

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

Log in to vote
1
Answered by 1 year ago

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!

0
ok thanks, i will try this JmoneyPlayzOfficial 49 — 1y
0
yo it worked, thank you JmoneyPlayzOfficial 49 — 1y
Ad

Answer this question