So its a gui local script but the cool down wont work what have i dont wrong???
local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent") local button_clicked = false local connection connection = script.Parent.Activated:Connect(function() button_clicked = true connection:Disconnect() connection = true end) local readz = true local function punch(connection,readz, gameProcessed) if connection ~= false and readz then connection = false punchEvent:FireServer() readz = false wait(0.5) connection = true readz = true print("clicked!!") end end script.Parent.MouseButton1Down:Connect(punch) -----------------
I think it's because in the punch() function you want the arguments: connection, readz and gameProcessed but they are not given when you run the function, they are nil. I think you want to check if the connection variable from line 5 is true or false. Try to remove the arguments inside the function. It should look like this:
local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent") local button_clicked = false local connection connection = script.Parent.Activated:Connect(function() button_clicked = true connection:Disconnect() connection = true end) local readz = true local function punch() --This line was changed if connection ~= false and readz then connection = false punchEvent:FireServer() readz = false wait(0.5) connection = true readz = true print("clicked!!") end end script.Parent.MouseButton1Down:Connect(punch) -----------------