Hello! So, I’ve been creating an effect for my UI button in which it tween’s its rotation once a mouse enters and then again when it leaves.
Here is the script (it is a local script inside of an Image Button):
local tweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Linear,Enum.EasingDirection.Out, 0, true)
script.Parent.MouseEnter:Connect(function(x, y)
print("Entered")
local tween = ts:Create(
script.Parent,
tweenInfo,
{Rotation = -40}
):Play()
end)
script.Parent.MouseLeave:Connect(function(x, y)
print("Left")
local tween2 = ts:Create(
script.Parent,
tweenInfo,
{Rotation = 0}
):Play()
end)
Both the “Entered” and “Left” prints show up when I test, yet it still doesn’t tween. What could be the problem?
Wait…
is script.Parent
a GUI Class
like a textbox, a text button?
local Button = script.Parent --to keep it clean I guess
local ButtonInfo = TweenInfo.new(0.8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true)
local TweenService = game:GetService("TweenService")
local Rotation1 = {
Rotation = -40
}
local FinalRotation = {
Rotation = 0
}
Button.MouseEnter:Connect(function()
print("Entered")
local NewTween = TweenService:Create(
Button,
ButtonInfo,
Rotation1
)
NewTween:Play()
end)
Button.MouseLeave:Connect(function()
print("Left")
local NewTween = TweenService:Create(
Button,
ButtonInfo,
FinalRotation
)
NewTween:Play()
end)
Fixed it for you
Yes it is, it’s an Image Button.
This script didn’t work either, it seems to be the same as mine, just with more variables such as Button and FinalRotation just to keep it cleaner. Thanks!
weird, I tested the script and it worked fine…
Try publishing the game and rejoining it
Don’t mind the other scripts, I’m working on a new ban system for my game…
That’s weird, my game has been published (it is private right now) and has all the security settings such as the one for API services and the HTTP ones on. Here is a video of how it looks like for me:
Yes, the prints work for me too, they show up when my mouse enters and leaves, but the tween is not working.
if the sweeper ball’s tween is working, you probably messed up the Rotation Tween Goals or the tween creation
I’ve noticed you didn’t include TweenService in the script you’ve provided me, but I’m pretty sure you cutted it out for error
moochezz
(moochezz)
June 8, 2021, 3:54pm
#15
Try wrapping Rotation
in a Vector3
.
@moochezz the rotation works, and I’ve tried that myself
Oh yes, I did call tweenService as ts in the script, but forgot to write it in the one I put here on devforum.
How would I do that? Thanks!
moochezz
(moochezz)
June 8, 2021, 3:56pm
#19
{Rotation = Vector3.New(-40, 0, 0)} -- put rotation into here