Ok so this script is when the player touch this they morph into the package in the script but if i put these in spawns a person from the other team can just run up and morph into this one so how would i add team only on this?
function ChangeMe(hit) if hit.Parent == nil then return end if (hit.Parent:findFirstChild("Humanoid") == nil) then return end local human = hit.Parent:findFirstChild("Humanoid") local char = hit.Parent local player = game.Players:GetPlayerFromCharacter(hit.Parent) if (human ~= nil) and debounce == false then debounce = true originals = char:getChildren() for w = 1, #originals do if originals[w].className == "CharacterMesh" then originals[w]:remove() end end meshes = script:getChildren() for y = 1, #meshes do copy = meshes[y]:clone() copy.Parent = char end end wait(0) debounce = false end script.Parent.Touched:connect(ChangeMe)
You would want to check if the player's TeamColor is equal to the TeamColor of the team you want. This can be achieved with a simple if statement.
local TeamName = "TEAMNAMEHERE" --Change TEAMNAMEHERE to the name of your team. We will be using this in the if statement below. function ChangeMe(hit) if hit.Parent == nil then return end if (hit.Parent:findFirstChild("Humanoid") == nil) then return end local human = hit.Parent:findFirstChild("Humanoid") local char = hit.Parent local player = game.Players:GetPlayerFromCharacter(hit.Parent) if human and not debounce and player and game.Teams:FindFirstChild(TeamName) and player.TeamColor == game.Teams[TeamName].TeamColor then --Checks if human is not nil, deboune is false, player is not nil, the team you want is not nil and if the player's TeamColor equals the team's TeamColor. The TeamColor will be different depending on the name of the team. debounce = true originals = char:getChildren() for w = 1, #originals do if originals[w].className == "CharacterMesh" then originals[w]:remove() end end meshes = script:getChildren() for y = 1, #meshes do copy = meshes[y]:clone() copy.Parent = char end end wait(0) debounce = false end script.Parent.Touched:connect(ChangeMe)
I hope my answer helped you. If it did, be sure to accept it.