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)
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)
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?