i made this attack script for a gui buttom but it wont play the function...
local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent") local Button = script.parent.MouseButton1Down local button_clicked = true -- Don't use MouseButton1Down. Think of your mobile and console players! local connection connection = script.Parent.Activated:Connect(function() button_clicked = false connection:Disconnect() connection = nil end) local ready = true local function punch(inputObject, gameProcessed) if connection == true and ready then print("uhhhh workin") punchEvent:FireServer() ready = false wait(0.5) ready = true end end UserInputService.InputBegan:Connect(punch) -----------------
local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent") local Button = script.parent.MouseButton1Down local button_clicked = true -- Don't use MouseButton1Down. Think of your mobile and console players! local connection connection = script.Parent.Activated:Connect(function() button_clicked = false connection:Disconnect() connection = nil end) local ready = true local function punch(inputObject, gameProcessed) if connection ~= nil and ready then print("uhhhh workin") punchEvent:FireServer() ready = false wait(0.5) ready = true end end UserInputService.InputBegan:Connect(punch) -----------------
This should work.