I have a gui that appears when you hold down your left mouse button and I'm trying to make it so that if you hover your mouse over a button and let go of the left button, it does something, but it doesn't seem to work for me.
This is the code I'm using right now:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local GreenEntered = false Green.MouseEnter:connect(function() GreenEntered=true ExpandGreen() end) Mouse.Button1Down:connect(function() if GreenEntered == true then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=100 end end
first of all, its good to realize that clicking a button is not possible unless you are indeed hovering over it. therefore, that GreenEntered variable is pointless.
Secondly, Button1Down is not an event of Mouse. Its an event of a button (actually the event is MouseButton1Down). Which is never declared here.
MouseEnter is also not an event of Green, which is never referenced either.
What you need is to reference the button. If your script is parented to the button, then you can type
local button = script.Parent
to get that button.
button.MouseButton1Up:Connect(function()
end)
MouseButton1Up is the event you are looking for. It fires when you let go of the left mouse button.
please accept and upvote, thank you:)