Tweening CanvasPosition not the same on different Devices

Hello, so I’ve been trying to tween the CanvasPosition of my ScrollingFrame whenever I click on a specific button, however, It’s not working at all, even if I didn’t use tweening, it would work but would not be the same position of different devices.

If you’re interested about my script, here it is:

-- // VARIABLES \\ --

local __TWEENSERVICE__ = game:GetService("TweenService");

local __FRAME__ = script.Parent.Parent;
local __SCROLLER__ = __FRAME__.ScrollingFrame;
local __BUTTON__ = __FRAME__.__CASH__;

-- // MAIN \\ --

__BUTTON__.MouseEnter:Connect(function()
	local __1__ = __TWEENSERVICE__:Create(__BUTTON__.UIScale,TweenInfo.new(0.55,Enum.EasingStyle.Elastic),{Scale = 1.15});
	__1__:Play()
	local __2__ = __TWEENSERVICE__:Create(__BUTTON__,TweenInfo.new(0.55,Enum.EasingStyle.Elastic),{Rotation = -5});
	__2__:Play()
end)

__BUTTON__.MouseLeave:Connect(function()
	local __1__ = __TWEENSERVICE__:Create(__BUTTON__.UIScale,TweenInfo.new(0.55,Enum.EasingStyle.Elastic),{Scale = 1});
	__1__:Play()
	local __2__ = __TWEENSERVICE__:Create(__BUTTON__,TweenInfo.new(0.55,Enum.EasingStyle.Elastic),{Rotation = 0});
	__2__:Play()
end)

__BUTTON__.MouseButton1Click:Connect(function()
	local __1__ = __TWEENSERVICE__:Create(__BUTTON__.UIScale,TweenInfo.new(0.55,Enum.EasingStyle.Elastic),{Scale = 0.85});
	__1__:Play()
	task.wait(.1)
	local __2__ = __TWEENSERVICE__:Create(__BUTTON__.UIScale,TweenInfo.new(0.55,Enum.EasingStyle.Elastic),{Scale = 1});
	__2__:Play()
	local __3__ = __TWEENSERVICE__:Create(__SCROLLER__,TweenInfo.new(0.25,Enum.EasingStyle.Sine),{CanvasPosition = Vector2.new(0,__SCROLLER__.AbsoluteWindowSize.Y*__FRAME__.Position.Y)*0.750});
	__3__:Play()
end)
1 Like

Waiting for responses! Is anyone willing to help?

First of all:

I think it should be .Size.Y?

Second of all:
My eyes!
Please do not name your variables like that. It’s really difficult to read.
That said, everyone has their preferences. In this case though, having underscores in front of a variable name means it’s private (i.e. shouldn’t be accessible outside its scope).

Here’s a style guide: Roblox Lua Style guide

2 Likes

Haha my bad, just tryna make scripting look really fancy, anyways I tried doing “__FRAME.Position.Y” but it returned an error saying " Players.YourPlxDev.PlayerGui.MAIN.SHOP_UI.CASH.LocalScript:31: attempt to perform arithmetic (mul) on number and UDim"

1 Like

Apologies. Should be:
.AbsoluteSize.Y ← Vector2
not
.Size ← UDIM2

1 Like

It did something! However, I think there’s something wrong with the math I did previously so I’ll try to fix it myself, anyways that pretty much fixed my issue, thank you!

1 Like