Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I did a script with someone and now its mess up. can anyone help me please?

Me and someone from scripting helpers made this invisible script, that is Press m to activate and deactivate, turns body invisible but you can still see hats but no faces, and have a cooldown like 12 seconds to reuse. Somehow its not even working now after I test it out in my game anyone got a idea or can help me fix it up?

local UserInputService = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character and plr.Character:FindFirstChild('HumanoidRootPart')
local char = plr.Character
local Debounce = false --To prevent from happening too many times.
local Enabled = false --So it can be used again

UserInputService.InputBegan:Connect(function(Input,GPE)
    if Input.KeyCode == Enum.KeyCode.M then
        if Enabled == false and Debounce == false then
            Debounce = true
            for i,v in pairs(plr.Character:GetChildren()) do
                if v:IsA('BasePart') and not v.Name == 'HumanoidRootPart' then
                    v.Transparency = 1
                end
            end
            wait(3) --Debounce wait time
            Debounce = false
        elseif Enabled == true and Debounce == false then
            Debounce = true
            for i,v in pairs(plr.Character:GetChildren()) do
                if v:IsA('BasePart') and not v.Name == 'HumanoidRootPart' then
                    v.Transparency = 0
                end
            end
            wait(3) --Debounce wait time
            Debounce = false
        end
    end
end)

1 comment

0

You can always change the version history to the last version and you will get the script back

1 answer

✓ Accepted answer

Corrected version.

local UserInputService = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
local char = plr.Character
local Debounce = false --To prevent from happening too many times.
local Enabled = false --So it can be used again

UserInputService.InputBegan:Connect(function(Input,GPE)
    if Input.KeyCode == Enum.KeyCode.M then
        if Enabled == false and Debounce == false then
            Debounce = true
			Enabled = true -- This was not here I put it...
            for i,v in pairs(char:GetChildren()) do
                if v:IsA('BasePart') then
                    v.Transparency = 1
                end
            end
            wait(3) --Debounce wait time
            Debounce = false
        elseif Enabled == true and Debounce == false then
            Debounce = true
			Enabled = false -- I put this also.
            for i,v in pairs(plr.Character:GetChildren()) do
                if v:IsA('BasePart') and v.Name ~= 'HumanoidRootPart' then -- don't use and not == , prefer to use ~= which is not "not equal to ".
                    v.Transparency = 0
                end
            end
            wait(3) --Debounce wait time
            Debounce = false
        end
    end
end)

Thank you for reading ! Goodluck while scripting!

This discussion is preserved as it was. New answers, comments, and votes are closed.