How can I see arms only if player hold a tool on a Certain team

Hello !
So for the game, we need 1st person. So we took a script that make the arms visible when player goes on 1st person. We got this script :

local self,player = script.Parent,game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid") -- waits for the humanoid in the character



function antiTrans(part)
	if part and part:IsA("BasePart") and( part.Name=="LeftUpperArm"  or part.Name=="LeftLowerArm" or part.Name=="LeftHand" or part.Name=="RightUpperArm" or part.Name=="RightLowerArm" or part.Name=="RightHand") then -- checks if a part and is a arm
		part.LocalTransparencyModifier = part.Transparency
		part.Changed:connect(function (property)    
			part.LocalTransparencyModifier = part.Transparency--Changes the local modifyer(client side only)
		end)
	end
end

for _,v in pairs(char:GetChildren()) do
	antiTrans(v) -- adds all parts
end

But we would like to modify it only if a player is holding a tool, and if he’s on the human team

local self,player = script.Parent,game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid") -- waits for the humanoid in the character
local humans = game:GetService("Teams"):FindFirstChild("Team Name Here")
-- this gets the 'humans' team

function antiTrans(part)
--                                                          much easier to match
	if part and part:IsA("BasePart") and (string.find(part.Name, "Arm") or string.find(part.Name, "Hand")) and player.Team == humans then -- checks if a part and is a arm
		part.LocalTransparencyModifier = part.Transparency

		part.Changed:Connect(function(p)
            if p:find("Local") then return end

			part.LocalTransparencyModifier = part.Transparency--Changes the local modifyer(client side only)
		end)
	end
end

for _,v in pairs(char:GetChildren()) do
	antiTrans(v) -- adds all parts
end
2 Likes

Thanks !
Imma try to add the tool holding part !

I tried to do this bt it doesn’t seems to work :

local self,player = script.Parent,game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid") -- waits for the humanoid in the character
local notFPS = {
	"SCP-049",
	"SCP-457",
	"SCP-106",
	"SCP-745",
}

function antiTrans(part)
	if part and part:IsA("BasePart") and( part.Name=="LeftUpperArm"  or part.Name=="LeftLowerArm" or part.Name=="LeftHand" or part.Name=="RightUpperArm" or part.Name=="RightLowerArm" or part.Name=="RightHand") then -- checks if a part and is a arm
		part.LocalTransparencyModifier = part.Transparency
		part.Changed:connect(function (property)    
			part.LocalTransparencyModifier = part.Transparency--Changes the local modifyer(client side only)
		end)
	end
end

if player.Character:FindFirstChildWhichIsA("Tool") then
	for _,v in pairs(char:GetChildren()) do
		antiTrans(v) -- adds all parts
	end
end

When a player is holding a tool it gets movend from the Backpack to the player’s character so you can use FindFirstChild("NameOfTheTool")

1 Like

Ye we wanted to make 2 parts : Player hold a keycard, so we only show the right hand, player hold a rifle, and it show the two arms, I’m first trying to do it only when the players hold a tool, so I’m using for now

FindFirstChildWhichIsA("Tool")

If the script only runs the first time when it loads then if player.Character:FindFirstChildWhichIsA("Tool") then won’t work because it’ll only check once.

You should do:

char.ChildAdded:Connect(function(child)
   if child:IsA("Tool") then
       -- do stuff
   end
end)

My error was dumb ^^’
Imma make it works depending on the tool, and remove arm view if the player unequip the toom

Just a question :
How can I make it invisible when the player doen’t hold a tool?

I Don’t essentially know how to do that, I made a forum about it but i can’t still figure out away to do it.