Mobile Buttons Positions Error

Hi so i wanted to make my mobile buttons appear inside of the default TouchControlFrame with its respective position but there is an error here, and i don’t know why.

The main issue here is that the buttons are not placed correctly despite the fact that the positions mentionned in module 1 were correct

So i made a test with a spare script, spare ui and spare module before CTRL C / V’d on the main ones, i still haven’t found the solution.

MODULE 1 (ButtonsSetup)

local module = {}

module.Positions = {
 -- (the positions were CTRL C / V'd from a mobile screen)
 -- somehow goes into one wrong place
	["Above"] = UDim2.fromScale(0.852, 0.491); 
	["Medium"] = UDim2.fromScale(0.737, 0.597);
	["Below"] = UDim2.fromScale(0.689, 0.792)
}

local Decoy = script["Decoy#"] -- This is a cloned version of my image button

  -- This function below generates an ui with:
        -- Script parented to ui
        -- Position to place the ui
        -- nom = name in french
        -- player to not reference it again
function module.GenerateModeUI(Script:LocalScript, Position:UDim2, nom:StringValue, player:Player)
	
	local SecDecoy = Decoy:Clone()
	local Gui = player:WaitForChild("PlayerGui") --
	local Ui2 = Gui:WaitForChild("TouchGui") --
	local ControlFrame = Ui2:WaitForChild("TouchControlFrame") -- 3 LINES to get the frame of the mobile user (where jump button is included)
	local decoy2 = Script:Clone()
	
    -- This block below is the problem
	decoy2.Parent = SecDecoy
	SecDecoy.Parent = ControlFrame
	SecDecoy.Name = nom
	SecDecoy.Position = Position
	SecDecoy.Visible = true
	
end

--function module.GenerateSideUi()
-- (Don't mind this)
--end

return module

MAIN LOCALSCRIPT (MobileManagerUI)

local Plr = game:GetService("Players").LocalPlayer
local Gui = Plr:WaitForChild("PlayerGui")
local TG = Gui:WaitForChild("TouchGui")
local frame = TG:WaitForChild("TouchControlFrame")
local UIS = game:GetService("UserInputService")
local Script = require(script:WaitForChild("ButtonsSetup"))

if UIS.KeyboardEnabled and UIS.MouseEnabled then return end -- if they're on pc then cancel the script and end it

if UIS.TouchEnabled then -- if they're on mobile then:
	Script.GenerateModeUI(script.Parent.FirstPersonSwitch, Script.Positions["Above"], "Test1", Plr)
	Script.GenerateModeUI(script.Parent.FirstPersonSwitch, Script.Positions["Medium"], "Test2", Plr)
	Script.GenerateModeUI(script.Parent.FirstPersonSwitch, Script.Positions["Below"], "Test3", Plr)
end

   -- the 3 identical blocks above generates 3 buttons with their respective scripts, detailed positions, their name & 

"player" itself.

On this one below that text, shows the 3 expected buttons on their respective places and the 3 of them above are the result of the function (respective positions in module 1)

below this text shows its descendance
Capture d'écran 2025-04-21 214422

i’d gladly accept any effort to overcome this error :pray:

note: i found another error where sometimes the buttons just won’t spawn at all

i desperately need help please

pls idk what to do

if you’re not using offset, you can do UDim2.fromScale
second, i can’t really see the issue, the buttons have proper positions

maybe i’m just blind

1 Like

I never really used fromScale, i thought it was complex lol, i will resend the code with it, thank you for your time

and modify mine with it*

a

bumping again pls its stopping a huge chunk my progress

Are you using offset?

Also, you can use this plugin to change offset into scale.

hello, sorry for the huge delay, but i’m not using offset, and i already used the plugin, thanks for your help man

i give up atp

-

Just to let y’all know, i finally solved it, and it turns out that and can be used in tables

local table = {
[“above” and 1] = Vector3.new(bla bla…

its pretty sad seeing myself as a solution