I'm trying to make a script that changes your team when you touch the part
You can use a touched event to detect whenever an object touches the part, then determine whether or not the object is a player, and set their team.
Assuming that the team script is inside of the part:
local team = game.Teams.Team -- replace this with the directory to the team you want script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') and game.Players:FindFirstChild(hit.Parent.Name) then local plr = game.Players[hit.Parent.Name] plr.Team = team end end)
Script in part:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local teamColor = --[[ Put the colour of the team you want the player to be inserted to e.g. Really black, Forest green, Institutional white, etc. Make sure it is a string.]] local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.TeamColor = BrickColor.new(teamColor) end end)
Don't forget to accept the answer if I helped!
Closed as Not Constructive by cailir and SerpentineKing
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?