Heyo, поскольку вы пытаетесь анимировать, когда пользователь наводит курсор на рамку, выполните следующие действия ...
1) Создайте ScreenGui в StarterGui.
2) ДобавьтеКадр для ScreenGui, измените его имя на HoverFrame, мы будем слушать события мыши, чтобы переключать состояния анимации.
3) Добавить еще один кадр в ScreenGui, изменить его имя на TweenFrame, добавить кое-чток этому.Настройте его, переместите, вот что мы будем анимировать по всему экрану.
4) Добавьте LocalScript для ScreenGui.Дважды щелкните, чтобы открыть его, и добавьте его в скрипт ...
-- grab some UI Elements
local hoverFrame = script.Parent.HoverFrame
local testFrame = script.Parent.TweenFrame
-- make some variables
local TweenService = game:GetService("TweenService")
local currentTween
local onscreenPos = UDim2.new(0,0,0.443,0)
local offscreenPos = UDim2.new(0,0,0.914,0)
-- make a helper function for animating the frame
local function tweenToPos(thing, target)
local tweenInfo = TweenInfo.new(0.5, -- how long should this play (seconds)
Enum.EasingStyle.Bounce, -- << This will give you the bounce in look
Enum.EasingDirection.Out,
0, -- number of times to repeat
false, -- reverses
0) -- how many seconds to delay the animation
local propertyTable = {
Position = target,
}
local tween = TweenService:Create(thing, tweenInfo, propertyTable)
return tween
end
-- make another helper function for handling the animation tween
local function cancelTweenIfPlaying()
if currentTween then
if currentTween.PlaybackState == Enum.PlaybackState.Playing
or currentTween.PlaybackState == Enum.PlaybackState.Delayed
or currentTween.PlaybackState == Enum.PlaybackState.Paused then
currentTween:Cancel()
end
end
end
-- listen for when the mouse hovers over the button, and animate the frame
hoverFrame.MouseEnter:Connect(function(x, y)
-- if there is an animation playing, cancel it.
cancelTweenIfPlaying()
-- animate the frame to center stage
currentTween = tweenToPos(testFrame, onscreenPos)
currentTween:Play()
end)
-- listen for when the mouse stops hovering over the button
hoverFrame.MouseLeave:Connect(function(x, y)
-- if the tween is already running, cancel it
cancelTweenIfPlaying()
-- animate to offscreen
currentTween = tweenToPos(testFrame, offscreenPos)
currentTween:Play()
end)
Надеюсь, это помогло!