This is actually an example. You might wanna read other posts from this topic first before you post.
Iām sorry man I just wanted to help you a bit.
Oh sorry about that, I didnāt mean to disappoint you.
Is that sarcasm or like for real? Because I kinda canāt tell.
No, it isnāt. Iām actually sorry.
Oh alright. Thanks then. I guess.
Itās basically like a bindable event as mentioned by others. But to answer your question, youāll want to create a table that holds references to functions that you call when you fire your event. Then just call all the functions that subscribed to that specific event when you fire it, passing any data along that you fired.
You can probably use this to handle it for you
And bindable events will work pretty much the exact same way.
If you mean anything else though, this is about the extent you can get to, but realistically itās basically how roblox is doing it anyways. You canāt really use robloxs version directly though.
Thanks for the help!
Why does that matter?
Anyway, good solution! Thanks very much!
I would simply add a variable buttonDown
local button = script.Parent
local buttonDown = false
button.MouseButton1Down:Connect(function()
buttonDown = true
end)
button.MouseButton1Up:Connect(function()
buttonDown = false
end)
while task.wait(1) do
if buttonDown then
print("Button held down")
end
end
If you want a syntax closer to MouseButton1Hold
you can make a ModuleScript
local wrappedButton = {}
local buttonDown = false
wrappedButton.MouseButton1Hold = {
Connect = function(self, callback)
while task.wait() do
if buttonDown then
callback()
end
end
end,
}
function wrappedButton:BindToButton(button)
button.MouseButton1Down:Connect(function()
buttonDown = true
end)
button.MouseButton1Up:Connect(function()
buttonDown = false
end)
end
return wrappedButton
Then you can call it using
local wrapper = require(script.Parent.ModuleScript)
local button = script.Parent
wrapper:BindToButton(button)
wrapper.MouseButton1Hold:Connect(function()
print("hold")
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.