GUI position is different despite using scale

Hi!
I am trying to make a piece of my GUI tween in and out of view. I am having issues with the position despite using scale rather than offset. In studio, the GUI element sits off-screen, but as soon as I test it ingame, you can clearly see that it is on-screen when it’s set as ‘Visible’ and it tweens further down than it should. The position in the properties screen while watching the tween, however, is correct.

All help would be very appreciated :slight_smile:

How my UI looks in studio (and how it should look ingame) at the before & after positions set in the tween:
Before:


After:

Properties of the frame:


The tween script (In particular, line 65, 67, and 78):

	local TInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
	local MInfo = TweenInfo.new(3, Enum.EasingStyle.Cubic)
	
	local MainTween = TweenService:Create(LvlUp, MInfo, { Position = UDim2.new(0.432, 0, 0.01, 0)})
	MainTween:Play()
	
	MainTween.Completed:Wait()
	
	local Tween = TweenService:Create(LvlUp.Level, TInfo, { Transparency = 0.3 })
	local TextTween = TweenService:Create(LvlUp.Level.TextLabel, TInfo, { TextTransparency = 0 })
	Tween:Play()
	TextTween:Play()
	Tween.Completed:Connect(function()
		task.wait(3)
		local MainTween = TweenService:Create(LvlUp, MInfo, { Position = UDim2.new(0.432, 0, -0.2, 0)})
		local Tween = TweenService:Create(LvlUp.Level, TInfo, { Transparency = 1 })
		local TextTween = TweenService:Create(LvlUp.Level.TextLabel, TInfo, { TextTransparency = 1 })
		MainTween:Play()
		Tween:Play()
		TextTween:Play()
		MainTween.Completed:Wait()
		LvlUp:Destroy()
	end)

How the GUI works in real-play:

1 Like

UIelements have their anchorpoint in the top left by default. This is probably what’s messing it up. Set
AnchorPoint = Vector2.new(0,1)

Note: the frame will be higher so you’ll need to change the Y positions when itmoves down

You should also scale the SIZE element, since UI offset size may be replicated differently on certain devices

The size property is an offset on purpose. I don’t want it to change between devices.

Then you will most likely be having the same problem, since the UI gets positioned with a certain size in x/y coordinates

This solution makes it better but the tween still likes to hang lower than it should.


1 Like

I tried changing the size to a scale just to see how it’d behave and I have the same issue regardless. My UI position is just not being replicated ingame properly for some reason.

Make sure that the parents are also scaled

Seems like you’re tweening it to be centered at Y=0. This means, however, that half the frame extends below (into view). So move up by 0.5 * Size.Y

I believe the issue may be a property within the GUI called “IgnoreGuiinset”

Set that to true and give it a try.

1 Like

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