Was the problem fixed or still not?
No, it’s still not fixed. I’ll see if I can fix it. Do you have any idea what’s wrong with it?
I can’t really help as I am still unaware regarding what the issue is.
You need to hook/unkhook the mouse click event whenever the image label is unfocused/focused respectively.
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local imageLabel = script.Parent
local function onMouseButtonDown()
print("Hello world!")
end
local connection
connection = mouse.Button1Down:Connect(onMouseButtonDown)
local function onImageMouseEnter()
if connection.Connected then connection:Disconnect() end
end
local function onImageMouseLeave()
connection = mouse.Button1Down:Connect(onMouseButtonDown)
end
imageLabel.MouseEnter:Connect(onImageMouseEnter)
imageLabel.MouseLeave:Connect(onImageMouseLeave)
This sadly only works once. I can’t tween the ui back into the player’s screen.
The connection is disconnected/reconnected whenever the player’s mouse cursor enters/leaves the ImageLabel instance respectively.
It’ll work repetively, I can only assume you’ve made a mistake in your implementation.
The ui leaves the player’s screen fully, so the system thinks that the player isn’t hovering over it, I think.
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local imageLabel = script.Parent
local function onMouseButtonDown()
if script.Parent.Position == UDim2.new(0.5, 0, 0.5, 0) then
print("hi")
script.Parent.Parent.Receipt:TweenPosition(UDim2.new(1.096, 0, 0.5, 0, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 3))
script.Parent.Parent.ImageLabel:TweenPosition(UDim2.new(.5, 0, 1.4, 0, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 3))
end
end
local connection
connection = mouse.Button1Down:Connect(onMouseButtonDown)
local function onImageMouseEnter()
if connection.Connected then
connection:Disconnect()
end
end
local function onImageMouseLeave()
connection = mouse.Button1Down:Connect(onMouseButtonDown)
end
imageLabel.MouseEnter:Connect(onImageMouseEnter)
imageLabel.MouseLeave:Connect(onImageMouseLeave)
It does work, if I don’t tween the UI out of the player’s screen
Do you know how I can fix the fact that it thinks that the mouse left the uni when the ui is actually out of the player’s screen.