I want to call my functions when a Button is pressed or a hovered at.
But which function will be called when a button is pressed or hovered at?
OK, here’s that code then.
button.MouseButton1Click:Connect(function()
PauseMenuLeaveGame()
end)
button.MouseEnter:Connect(function()
ReturnToGame()
end)
Change the functions as you wish, they are just placeholders. Also specify the local path of “button”.
MouseButton1Click
fires when you click a button. MouseEnter
fires when you hover over a button.
Let me explain, What the script should do. Down below is this UI, When a button is pressed at the “Return to Game Button”, The UI will be not visible And when it hovers over “Return to Game Button” a UIStroke will be enabled. When the mouse leaves the UI stroke will be disabled.
When the player presses on the “Leave Game Button”, It will open another confirmation frame. And it will close the Pause UI. Also, When the player hovers over the Leave game button a UIStroke will be enabled. When the mouse leaves the UIStroke will be disabled. That’s it.
OK, here’s that code. Make sure to define LeaveButton and ReturnButton, and fill in the functions for UI stroke effects
local LeaveButton = script.Parent
local ReturnButton = script.Parent.ReturnButton
local function addUIStroke()
-- add UI stroke function here
end
local function removeUIStroke()
-- remove UI stroke function here
end
LeaveButton.MouseEnter:Connect(addUIStroke)
LeaveButton.MouseLeave:Connect(removeUIStroke)
ReturnButton.MouseEnter:Connect(addUIStroke)
ReturnButton.MouseLeave:Connect(removeUIStroke)
LeaveButton.MouseButton1Click:Connect(LeaveGame)
ReturnButton.MouseButton1Click:Connect(ReturnToGame)
Ok, I will try. I make sure to notify you.
Remember the confirmation function for leave game button
This doesn’t make much sense. Why are you connecting an event like this? If you’re only calling this function once, it shouldn’t be a function.
oh yes, i forgot that!
This text will be blurred
So, that’s what’s making the error?
Thank you!
It worked well.
This text is for DevFourm 30 words thing.
You don’t need to put [SOLVED] in the title. There’s already a checkmark next to the title saying it was solved.
I’m assuming you removed the ()
s here:
Because with them, it would call the function instead of connecting it.
Also I think the event is MouseLeave
, not MouseExit
. So since you said the script works, I’m assuming you have fixed those already. Just saying them incase anybody else wants to use the solution!
oops im stupid, you have to remove the brackets as you rightly pointed out, im really stupid
Alright, I fixed those, thanks for spotting them…
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.