Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Activated Ability, Hat Remover, Any Help?

Asked by 8 years ago

Okay So I have this tool that activates upon the "e" key being pressed. It turns your character invisible (Transparent). And I did the same with hats, but however I can only get one hat to go transparent. Does anyone know if there is a way to put a table into this putting all the hats into a table and then setting them to transparency 1?

Here is my script:

local mouse = game.Players.LocalPlayer:GetMouse()
function Light()
    local player = game.Players.LocalPlayer
    local playerChar = player.Character
    local playerLight = playerChar.Torso:FindFirstChild("Light")
    if playerLight then
        playerLight:Destroy()
    else
        local humanoid = playerChar:findFirstChild("Humanoid")
    if humanoid == nil then return end




    playerChar:findFirstChild("Head").Transparency = 0.98 
playerChar:findFirstChild("Torso").Transparency = 0.98 
playerChar:findFirstChild("Left Arm").Transparency = 0.98 
playerChar:findFirstChild("Right Arm").Transparency = 0.98 
playerChar:findFirstChild("Left Leg").Transparency = 0.98 
playerChar:findFirstChild("Right Leg").Transparency = 0.98 
playerChar:findFirstChild("Head"):findFirstChild("face").Transparency = 1 
local d = playerChar:GetChildren() 
    for i=1, #d do 
        if (d[i].className == "Hat") then 
            d[i].Handle.Transparency = 1

wait(10)

playerChar:findFirstChild("Head").Transparency = 0 
playerChar:findFirstChild("Torso").Transparency = 0 
playerChar:findFirstChild("Left Arm").Transparency = 0
playerChar:findFirstChild("Right Arm").Transparency = 0 
playerChar:findFirstChild("Left Leg").Transparency = 0
playerChar:findFirstChild("Right Leg").Transparency = 0 
playerChar:findFirstChild("Head"):findFirstChild("face").Transparency = 0 
for i=1, #d do 
        if (d[i].className == "Hat") then 
            d[i].Handle.Transparency = 0


script.LocalScript.Disabled = true
wait(0.000005)
player.PlayerGui.InvisibleAbility:Destroy()
    script:Destroy()

        end
        end
    end
            end
            end
        end
    end
end








mouse.KeyDown:connect(function(key)
key = key:lower()
if key == "e" then -- Change this to any Keys but I reccomand leaving it as [F] key.
    Light()
end
end)

-You may recognize the script, but I edited the toggle flashlight script so I can make my own abilities.

Answer this question