UI not tweening to the correct position

I want to make it so when you hover over a frame, the “Icon” tweens up

When I hover over it, it tweens northwest despite the script saying to go directly up, then back down when the players cursor leaves
https://gyazo.com/f64804a6b4a12e711d72027fa13e0752

Here is my explorer
image
Here are the properties of the image label I’m trying to tween

Here is my script:


local sfx = game.ReplicatedStorage.SFX

local ts = game:GetService("TweenService")

local backpack = script.Parent.Backpack
local rebirth = script.Parent.Rebirths
local shop = script.Parent.Shop
local crystals = script.Parent.Crystals
local info = script.Parent.Info
local profile = script.Parent.Profile
local rewards = script.Parent.Rewards
local setting = script.Parent.Settings
local upgrades = script.Parent.Upgrades

--Backpack

backpack.MouseEnter:Connect(function()
	backpack.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	backpack.Icon.Identify.UIStroke.Color = Color3.new(1, 0.74902, 0.396078)
	sfx.uihover:Play()
end)

backpack.MouseLeave:Connect(function()
	backpack.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	backpack.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--Rebirth

rebirth.MouseEnter:Connect(function()
	rebirth.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	rebirth.Icon.Identify.UIStroke.Color = Color3.new(1, 0.4, 0.4)
	sfx.uihover:Play()
end)

rebirth.MouseLeave:Connect(function()
	rebirth.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	rebirth.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--Shop

shop.MouseEnter:Connect(function()
	shop.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	shop.Icon.Identify.UIStroke.Color = Color3.new(0.380392, 1, 0.380392)
	sfx.uihover:Play()
end)

shop.MouseLeave:Connect(function()
	shop.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	shop.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--crystals

crystals.MouseEnter:Connect(function()
	crystals.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	crystals.Icon.Identify.UIStroke.Color = Color3.new(0.721569, 0.47451, 1)
	sfx.uihover:Play()
end)

crystals.MouseLeave:Connect(function()
	crystals.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	crystals.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--info

info.MouseEnter:Connect(function()
	info.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	info.Icon.Identify.UIStroke.Color = Color3.new(1, 0.207843, 0.207843)
	sfx.uihover:Play()
end)

info.MouseLeave:Connect(function()
	info.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	info.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--profile

profile.MouseEnter:Connect(function()
	profile.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	profile.Icon.Identify.UIStroke.Color = Color3.new(1, 0.972549, 0.227451)
	sfx.uihover:Play()
end)

profile.MouseLeave:Connect(function()
	profile.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	profile.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--rewards

rewards.MouseEnter:Connect(function()
	rewards.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	rewards.Icon.Identify.UIStroke.Color = Color3.new(0.721569, 0.611765, 0)
	sfx.uihover:Play()
end)

rewards.MouseLeave:Connect(function()
	rewards.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	rewards.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--settings

setting.MouseEnter:Connect(function()
	setting.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	setting.Icon.Identify.UIStroke.Color = Color3.new(0.462745, 0.462745, 0.462745)
	sfx.uihover:Play()
end)

setting.MouseLeave:Connect(function()
	setting.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	setting.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

--upgrades

upgrades.MouseEnter:Connect(function()
	upgrades.Icon:TweenPosition(UDim2.new(0, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	upgrades.Icon.Identify.UIStroke.Color = Color3.new(0.278431, 0.478431, 0.184314)
	sfx.uihover:Play()
end)

upgrades.MouseLeave:Connect(function()
	upgrades.Icon:TweenPosition(UDim2.new(0.5, 0,0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )

	upgrades.Icon.Identify.UIStroke.Color = Color3.new(0, 0, 0)
end)

2 Likes

You forgot to set the first Udim2.new() variable to 0.5

Should be:

rebirth.Icon:TweenPosition(UDim2.new(0.5, 0,0.3, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, .2, true )
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.