How do you change the Y value of a Gui with a tween?

For a game that I’m making, I’m trying to making a custom inventory system with custom slots. I wanted to make it so that the slot would rise slightly when the player equipped it. I made a tween service that moves the gui up, but I came across a problem.

This is the code that tells the tween where to move to (third argument to the tween):

local GuiPos = { Position = UDim2.new(slotPos.Position.X, 0, 0.9, 0) }

My problem is that no matter what I change in the 3rd argument, the tween always puts the gui in the same Y position. (The X position works properly).
Here’s a video to show you what I mean
robloxapp-20201230-1713128.wmv
The slot is moving way too far up and I can’t seem to change that.

How can I change it so that the tween puts the gui in a different Y position?

That code alone should work since the y value is being assigned, there must be something else conflicting it, can you post the whole tween code?

You mean you want it to tween it to a random Y position?

local tweenService = game:GetService("TweenService")
local slotTransition = function(slot) 
	local slotTable = {localScreenGui.emptySlot1, localScreenGui.emptySlot2, localScreenGui.emptySlot3}
	local tweenInInfo = TweenInfo.new(
		1,
		Enum.EasingStyle.Back,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	local slotPos = nil
	if slot == 1 then
		slotPos = localScreenGui.emptySlot1
	elseif slot == 2 then
		slotPos = localScreenGui.emptySlot2
	elseif slot == 3 then
		slotPos = localScreenGui.emptySlot3
	end
	local GuiPos = {
		Position = UDim2.new(slotPos.Position.X, 0, 0, 0)
	}
	local tweenIn = tweenService:Create(slotPos, tweenInInfo, GuiPos)
	tweenIn:Play()
end

I’m not sure if you need more context but this is the function that controls the tween.

No, I want the Gui to go to a specific Y position but no matter how I change the 3rd parameter of the UDim2 statement, it always goes to the same position.

Hm, maybe changing the easingstyle might work.

Did you tried to print out the slotPos?
It’s maybe not changing at all.

The slotPos variable is used so that if I press 1, slot number one goes up. That’s working okay.
My problem is that the slots are moving up way too far and I can’t seem to change that.
Here’s what I mean:
robloxapp-20201230-1713128.wmv (310.0 KB)

I tried that and it didn’t work. I edited my post so that there’s a video if you would like to see what’s happening.

I’m not sure why this is happening but apparently having this

slotPos.Position.X

In the first argument dictates the Y value aswell. I have no clue how, but when I removed it I was able to adjust the Y value.

1 Like