local isActive = false
function main()
getCowButton.MouseButton1Down:Connect(function()
print('Down Triggered')
isActive = true
GetCowModule.mouseButton1Down(player)
end)
player:GetMouse().Button1Up:Connect(function() --Had to do getmouse because glitch where you move cursor off of button and it still fired event
print("Up Triggered")
if isActive then
print("Inside")
GetCowModule.mouseButton1Up(player)
isActive = false
end
end)
ShopHandler.main(player)
end
This code is pretty buggy. When I hold down on the button then lift up, it will stay active. If I hold down on the button then move off of the button then lift, then it will not be active (this is what i want), but if I hold down on the button then move to a different GUI then lift up then it will stay active. Why is this happening and how can I fix it?
Are you saying that if the mouse moves to a different button while down, it should activate the new one and not the old one? In that case it would be simpler to only detect when the mouse goes up.
Nah so like theres only one button, but if you press down on that button and move to any different gui (whether its a frame, label, button, etc) it will not detect when mousebutton up for some reason
I got nothing for that. It seems like one of those Roblox quirks. Is there any reason not to just detect if a button is unclicked on, and forego the down part?
Idk what that question is asking. This feature of my game is basically that as long as youre holding down starting on that button, you will gain a stat until you release ur mouse. This means it doesnt matter where ur mouse ends up, it needs to stop once you release it.
Oh, I thought it was just a normal button. Do the other GUI elements have Interactable disabled? If that doesn’t work, you could try using UserInputService:IsMouseButtonPressed(), but that needs to be checked every frame.