Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I tween a Gui that when you hover over appears?

Asked by 7 years ago

I've managed to make a gui that when you hover over a door it will make a Gui visible. I don't like the way the Gui just pops into existance so I tried tweening it. Didn't work out too well. This is my attempt at tweening;

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local frame = script.Parent:WaitForChild('FrameGUI')
local toggle = false
local Door = 
--LIST OF IN GAME DOORS--
            game.Workspace.Door1.Door.Clickbox or
            game.Workspace.Door2.Door.Clickbox
--LIST OF IN GAME DOORS--

Mouse.Move:connect(function()
    if Mouse.Target and Mouse.Target == Door then
        Player.PlayerGui.DoorGui.SpecialHoverGui.Visible = true
    elseif Mouse.Target and Mouse.Target ~= Door then
        Player.PlayerGui.DoorGui.SpecialHoverGui.Visible = false
    end
end)


Mouse.Move:connect(function()
 if script.Parent.Visible == false then
  frame:TweenPosition(UDim2.new(0.5,-250,0.5,-200), 'Out', 'Bounce', 1)
  script.Parent.Visible = true
 else
  frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200), 'Out', 'Bounce', 1)
  script.Parent.Visible = true
 end
end)

1 answer

Log in to vote
0
Answered by
Voltoxus 248 Moderation Voter
7 years ago

Add another argument, true to the end

frame:TweenPosition(UDim2.new(0.5,-250,0.5,-200), 'Out', 'Bounce', 1, true)

This will make the tween function override any prior ones effecting the gui. So if you hover off the door before the tween finishes it will halt and jump to the latest tween call. try it out.

Ad

Answer this question