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
i’d gladly accept any effort to overcome this error
note: i found another error where sometimes the buttons just won’t spawn at all