The title is pretty self-explanatory.
This is the script I already have:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
wait(0.01)
for i,Child in pairs(Character:GetChildren()) do
if Child:IsA("Part") or Child:IsA ("MeshPart") then
Child.Transparency = 0.99
end
end
wait(0.01)
for i,Child in pairs(Character:GetChildren()) do
if Child:IsA('Accessory') then
Child.Handle.Transparency = 0.99
end
end
Character.Head.face.Transparency = 0.99
end)
end)
I did not write this script.
I specifically want the player to go invisible if they are on a certain team touching a certain part.
You don’t need any of these functions to do what you need to do.
Here’s the script:
--//Services
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
--//Variables
local Part = workspace.Part --//Reference your part
--//Functions
Part.Touched:Connect(function(hit)
--//Check for player
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player and player.Team == Teams.MyTeam then
--//Make character invisible
local character = player.Character
for i, descendant in ipairs(character:GetDescendants()) do
if descendant:IsA("BasePart") or descendant:IsA("Decal") then
descendant.Transparency = 1
end
end
end
end)
You would need to connect it to a touched function, and check the team.
local part = --part to touch
local team = --needed team
part.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr and plr.Team == team then
local Character = plr.Character
wait(0.01)
for i,Child in pairs(Character:GetChildren()) do
if Child:IsA("Part") or Child:IsA ("MeshPart") then
Child.Transparency = 0.99
end
end
wait(0.01)
for i,Child in pairs(Character:GetChildren()) do
if Child:IsA('Accessory') then
Child.Handle.Transparency = 0.99
end
end
Character.Head.face.Transparency = 0.99
end
end)