How can i make sure that the canvas position of pc and the mobile one are the same?

  1. What do i want to achieve? I want to do a round system with countries flags that select a random country
    image

  2. What is the issue? I did a script with tweening the canvas position of the scrollingframe (i know it is not the best way, but i’m really bad at scripting xD). The problem is that the canvas position of mobile and the canvas position of pc are different! How can i make sure that the canvas position of pc and the mobile one are the same?

  3. What solutions have i tried so far? I found this: Scrolling Frame canvas [ Failed Tweening to correct position ] - #7 by pixelgodess, but i don’t understand it… And it didn’t work

This is my script of the round system and the tween if you are interested

local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")



local function toMS(s)
	return string.format("%02i:%02i", s/60%60, s%60)
end

while true do
	--Intermission

	for i = 10, 0, -1 do

		Status.Value = "Intermission: ".. i
		task.wait(1)


	end


local randomnumber = math.random(1, 1)
	if randomnumber == 1 then 
		local UserInputService = game:GetService("UserInputService")


		script.Parent.Parent.Visible = true
		
	local tweenservice = game:GetService("TweenService")
	local twinfo = TweenInfo.new(
		2,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)


		local tween = tweenservice:Create(script.Parent, twinfo, {CanvasPosition = Vector2.new(200, 0)})
				
		tween:Play()
		task.wait(twinfo.Time + 1)
		Status.Value = "Italy Chosen"
		wait(3)
		script.Parent.Parent.Visible = false
		script.Parent.CanvasPosition = Vector2.new(0, 0)
		task.wait(3)
		
		--tp map
		
		for i = 10, 0, -1 do
			Status.Value = "Game: "..toMS(i)
			task.wait(1)
		end
		
		--Teleport to Lobby
end
	end

Thanks very much for help, all answers are welcome :smiley:

2 Likes

Uh this is the example with the script of that gui (Scrolling Frame canvas [ Failed Tweening to correct position ] - #7 by pixelgodess) @pixelgodess pixelgod

local tweenservice = game:GetService("TweenService")
local tween = tweenservice:Create(script.Parent, twinfo, {CanvasPosition = Vector2.new((script.Parent.AbsoluteWindowSize * script.Parent.Italy.Position)*10)})

image
this is the image of the gui
image
and this is the error

1 Like

First of all, use scale, and mix it with offset if you wish.

Scale works with proportions (meaning that in every device the gui will be similarly in the same position)

While offset uses pixels, useful for making text bigger when on mobile (example)

Second of all, in your tween you are passing data that cannot be multiplied with a vector2

1 Like

This gives a Vector2 value, not a Number.

try script.Parent.AbsoluteWindowSize.X

1 Like

Ty for the answer but…

local tween = tweenservice:Create(script.Parent, twinfo, {CanvasPosition = Vector2.new((script.Parent.AbsoluteWindowSize.X * script.Parent.Italy.Position)*10)})
tween:Play()

image
…with this script It gives me this error

You are multiplying the udim2 with a number

Instead, multiply it with a udim2 constructor

1 Like

Ty for your answer

look my positions
image
(there is the uiaspectratio)

but i have to put the offset insted of the normal? Sry i don’t understand very :\

1 Like

Hey, ignore my previous reply, you’d need to use

script.Parent.AbsoluteWindowSize.X.Scale
1 Like

uh sry, i didn’r understand xD… I try it rn but tysm for the answers again

1 Like

No, you are doing good, scale is generally recommended, offset should only be used when you know what you are doing and as a mixture with scale

2 Likes
local tween = tweenservice:Create(script.Parent, twinfo, {CanvasPosition = Vector2.new((script.Parent.AbsoluteWindowSize.X.Scale * script.Parent.Italy.Position)*10)})
tween:Play()
1 Like

image
it gives me this error…
image

Maybe there is another solution for make sure that the canvas position of pc and the mobile one are the same…

Whoops sorry haha! I forgot AbsoluteWindowSize used only offset with Vector2.new! I’ll try to help you further

1 Like

Wouldn’t he need to use AbsoluteSize?

2 Likes

Definitely ________________________

1 Like

There is a pretty good plugin I use for guis if you look up Scale in the plugin toolbox you will find it.

1 Like

local XScale = GuiObject.AbsoluteSize.X / Camera.ViewportSize.X

2 Likes

Ty for the answer… What is this plusing?

Ty for the answer, but what do you mean by camera? I need a camera? Where can i spawn it?

Ty for your answer. How can i use it? (in what way?)