So, I’m trying to make a pets button to open a GUI with them (just like in simulators), the problem is, that the UI does not open all the time the button is pressed. I have no clue why this is happening and it may be just a dumb error of mine. (Also I know that this is my second question in a matter of 2 days)
Script of the button:
local ts = game:GetService("TweenService")
local function TweenUI(object, info, goal)
local tween = ts:Create(object, info, goal)
tween:Play()
end
local tweenInfo = TweenInfo.new(
.2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0
)
local goal = {
["Position"] = UDim2.new(0.05, 0,0.049, 0)
}
local goalOutL = {
["Position"] = UDim2.new(0.043, 0,0.038, 0)
}
script.Parent.MouseButton1Down:Connect(function()
script.Parent.Parent.Parent.PetsUI.Enabled = true
script.Parent.Parent.Enabled = false
TweenUI(script.Parent.Parent.Parent.PetsUI.Gradient, tweenInfo, goal)
TweenUI(script.Parent.Parent.Parent.PetsUI.Outline, tweenInfo, goalOutL)
local blur = Instance.new("BlurEffect")
blur.Parent = workspace.CurrentCamera
blur.Size = 12
end)
Had to change it to imagelabel, for some reason the plugin imported the icon as a button, and interference between the two was made, cause it registered a click on the imageButton, not the pets button. Thanks for you time though, I appreciate it a lot!
How about check if the mouse is hovering the Icon with MouseEnter and MouseLeave functions and use Mouse.Button1Down:
local IsHovering = false
Icon.MouseEnter:Connect(function() IsHovering = true end)
Icon.MouseLeave:Connect(function() IsHovering = false end)
Mouse.Button1Down:Connect(function()
if IsHovering then
...
end
end