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

How do I make it so whenever you have a tool equipped, this script disables?

Asked by 2 years ago

Code: local rp = game:GetService("ReplicatedStorage") local Combat = rp:WaitForChild("Combat")

local UIS = game:GetService("UserInputService") local debounce = false local cds = { 0, 1 } local sequence = "" local curr = 0 local prev = 0

UIS.InputBegan:Connect(function(input,isTyping) if not isTyping then if input.UserInputType == Enum.UserInputType.MouseButton1 then if debounce == false then debounce = true curr = os.clock()

            local PT = curr - prev
            if PT < 1 then 
                sequence = sequence.."L"
                if string.len(sequence) > 4 then 
                    sequence = "L"
                end
            else 
                sequence = "L"
            end

            Combat:FireServer(sequence)
        end
    end
end

end)

Combat.OnClientEvent:Connect(function(bool) prev = curr

if bool then 
    wait(cds[2])
    debounce = false 
else 
    debounce = false 
end

end)

0
script was posted pretty poorly but first time posting on here, help would be much appreciated. RoyaIMonster 2 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Use the Equipped and Unequipped function:

--Inside of the Tool
function CoolFunction()
    game.Workspace.LocalScript.Disabled = true --Put wherever the script is inside of here(except for the 'Disabled' and 'True' part)
end

function SadEndingCoolFunction()
    game.Workspace.LocalScript.Disabled = false --Put wherever the script is inside of here(except for the 'Disabled' and 'False part')
end


script.Parent.Equipped:Connect(CoolFunction)
script.Parent.Unequipped:Connect(SadEndingCoolFunction) --When unequipped, it enables again (Remove the function and this line if you don't want it)

Also, the way you do insert the Lua Code is by: Pressing the Lua button, And writing in between the two Lines of ~~~~~~~~~~~~~~~~~~~~~~~~

0
thank you, it worked! RoyaIMonster 2 — 2y
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question