I made a script that turns the player completely transparent, the only problem is I can't make the players hats transparent. How would I make every hat in the player transparent?
Code (Local script):
local plr = game.Players.LocalPlayer function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Z then plr.Character.Head.Transparency = 1 plr.Character.Torso.Transparency = 1 plr.Character["Right Arm"].Transparency = 1 plr.Character["Left Arm"].Transparency = 1 plr.Character["Right Leg"].Transparency = 1 plr.Character["Left Leg"].Transparency = 1 end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
See, the issue with changing transparency this way is that you don't know the hat's name. That means you'd have to loop through items to see if they're a hat. But then you could just include the parts in the loop. Here's how I'd do it:
--This will not work for FE games, or would only show him his own body as transparent local plr = game.Players.LocalPlayer local debounce = true function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Z and debounce then debounce = false for a,part in pairs (plr.Character:GetChildren()) do if part.ClassName == "Part" then -- their torso,head,legs and arms part.Transparency = 1 elseif part.ClassName == "Accessory" then part.Handle.Transparency = 1-- this should make all hats transparent now end end wait(1) debounce = true end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)