im not great at script guis but i made this little punch thing but the function wont play when i click the button.. pls help!
--Made by ParionFire local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent") local Button = script.parent.MouseButton1Down local ready = true local function punch(inputObject, gameProcessed) if Button == true and ready then print("uhhhh workin") punchEvent:FireServer() ready = false wait(0.5) ready = true end end UserInputService.InputBegan:Connect(punch) -----------------
You connect to them. You don't use them as conditions. You're explicitly comparing it to true
, which Button == true
immediately evaluates to false
.
You can do something like this though:
local button_clicked = false -- Don't use MouseButton1Down. Think of your mobile and console players! local connection connection = script.Parent.Activated:Connect(function() button_clicked = true connection:Disconnect() connection = nil end)
And in your control structure:
if button_clicked and ready then -- thing end