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

Team Change BUTTON possible? [closed]

Asked by 7 years ago
Edited 7 years ago

is it possible to make a button that when you touch it it changes your team? If yes then is this correct??

function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then -- if a humanoid exists, then
humanoid.SetTeam("Fire")
end
end
script.Parent.Touched:connect(onTouch)
0
yes abnotaddable 920 — 7y
0
is this correct? SwagnLag -2 — 7y
0
'If yes then is this correct?' - can you not test it yourself? shadow7692 69 — 7y
0
Good hsilver 0 — 7y

Closed as Not Constructive by XAXA, abnotaddable, ObscureIllusion, and PyccknnXakep

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 7 years ago

The best way to do this would be:

script.Parent.Touched:connect(function(h)
    local plr = game.Players:GetPlayerFromCharacter(h.Parent) --this will get the actual player object from the character, since h would typically be like a body part, such as Head, and head.Parent = the player's character.
    if plr then --checking to see if it actually is a player
        plr.Team = game.Teams["Fire"] --if so proceed to make their team the "Fire" team.
    end
end)
Ad