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

How to make this script only work when a certain tool is equipped and mouse button is clicked?

Asked by 4 years ago

Hello, I am trying to create a script to where an animation is triggered only when the left mouse is clicked AND a tool is equipped. However, I keep getting this error thats says   

61: Expected ')' (to close '(' at line 54), got <eof>  -  Studio  -  Combat:61 local Player = game:GetService("Players").LocalPlayer

This is my script:

local rp = game:GetService("ReplicatedStorage") local Combat = rp:WaitForChild("Combat") local Tool = StarterPack.Punch local Equip = false

local UIS = game:GetService("UserInputService")

local debounce = false local cd = .10

local currTime = 0 local prevTime = 0 local count = 0 local Equip = false

UIS.InputBegan:Connect(function(InputObject,Equip) if not Equip then return elseif input.UserInputType == Enum.UserInputType.MouseButton1 then if Equip then if debounce == false then debounce = true currTime = tick()

        local passedTime = currTime - prevTime
        if passedTime < 1 then
            --Can Continue the Combat Combo
            count = count + 1
            if count > 5 then
                count = 1
            end
        else

            count = 1
            end


            Tool.Unequipped:Connect(function()
                Equip = false
        end)
            Tool.Equipped:Connect(function()
                Equip = false
        end)


        Combat:FireServer(count)

    end
end

Combat.OnClientEvent:Connect(function()

prevTime = currTime

wait(cd)
debounce = false
    end)

Answer this question