Prints work on PC but not mobile?

  1. What do you want to achieve?
    Trying to implement a radial backpack for mobile devices, so I added two print statements (“Tool parented 1” and “Tool parented 2”) to test whether the frame was being parented to ‘Wheel’ button. The two print statements print when on PC but not on mobile.

  2. What is the issue?
    The text is printed while on PC but not on mobile devices. I want it so the ToolRadial.Frame.Parent = Wheel regardless of when the player is on a PC or mobile device.

PC


As you can see, in the Output, both prints are there. In the Workspace, you can also see that the Frame is Child to the Wheel button. You can also see that on the screen, the radial backpack appears.

Mobile

As you can see, in the Output, both prints do not print. In the Workspace, you can also see that the Frame is not Child to the Wheel button. You can also see that on the screen, the radial backpack does not appear.

  1. What solutions have you tried so far?
    Tried adding the BackpackRadial:Rebuild() function for the ‘mbutton’ but that caused my studio to lag out, so I don’t think that worked.

Overall, I want to know why these print statements aren't printing on mobile, but are printing on PC?

This will hopefully help me solve my issue with the frame not being parented to the Wheel button.

Radial Backpack LocalScript in StarterPlayerScripts

-- CONSTANTS

local LOCALPLAYER = game:GetService("Players").LocalPlayer

local LIGHTING = game:GetService("Lighting")
local STARTERGUI = game:GetService("StarterGui")
local UIS = game:GetService("UserInputService")
local CONTEXT = game:GetService("ContextActionService")
local RUNSERVICE = game:GetService("RunService")

local Blur = script:WaitForChild("Blur")
local RBackpack = script:WaitForChild("RadialBackpack")
local Wheel = RBackpack:WaitForChild("Wheel")

local pModule = require(LOCALPLAYER.PlayerScripts:WaitForChild("PlayerModule"))
local cModule = pModule:GetCameras()

local GuiLib = script:WaitForChild("GuiLib")
local Lazy = require(GuiLib:WaitForChild("LazyLoader"))


--

local Tools = {}
local HoverIndex = 1
local ToolRadial = nil
local Status = false

local Spring = Lazy.Utilities.Spring.new(1, 0.1, 1, Status and 1 or 0)

-- Private Functions

local function lerp(a, b, t)
	return (1 - t)*a + t*b
end

-- Public Functions

local BackpackRadial = {}

function BackpackRadial:GetHumanoid()
	return LOCALPLAYER.Character and LOCALPLAYER.Character:FindFirstChild("Humanoid")
end

function BackpackRadial:Rebuild()
	if (ToolRadial) then
		HoverIndex = 1
		ToolRadial:Destroy()
		ToolRadial = nil
	end
	
	print ("Tool parented 1")
	ToolRadial = Lazy.Classes.RadialMenu.new(#Tools, 0.5, 0)
	ToolRadial.Frame.Parent = Wheel
	print ("Tool parented 2")

	for i, tool in next, Tools do
		local label = nil
		
		if (tool.TextureId ~= "") then
			label = Instance.new("ImageLabel")
			label.Image = tool.TextureId
		else
			label = Instance.new("TextLabel")
			label.Text = tool.Name
			label.Font = Enum.Font.Gotham
			label.TextColor3 = Color3.new(1, 1, 1)
			label.TextScaled = true
		end
		
		label.BackgroundTransparency = 1
		label.Size = UDim2.new(1, 0, 1, 0)
		label.Parent = ToolRadial:GetAttachment(i)
	end
	
	ToolRadial:SetDialProps{
		ImageColor3 = Color3.new(1, 1, 1),
		ImageTransparency = 0.7	
	}
	
	ToolRadial.Hover:Connect(function(oldIndex, newIndex)
		HoverIndex = newIndex
		if (oldIndex) then
			ToolRadial:GetRadial(oldIndex).ImageColor3 = Color3.new(0, 0, 0)
		end
		ToolRadial:GetRadial(newIndex).ImageColor3 = Color3.new(1, 1, 1)
	end)
end

function BackpackRadial:Show(bool)
	Status = bool
	Spring.t = Status and 1 or 0
	cModule.activeCameraController.gamepadSensitivity = Status and 0 or 1
end

function BackpackRadial:OnOpen()
	self:Show(true)
	
	local humanoid = self:GetHumanoid()
	if (humanoid) then
		humanoid:UnequipTools()
	end
end

function BackpackRadial:OnClose()
	self:Show(false)
	
	local humanoid = self:GetHumanoid()
	if (humanoid) then
		humanoid:EquipTool(Tools[HoverIndex])
	end
end

function BackpackRadial:OnStep(dt)
	Spring:Update(dt)
	
	local x = Spring.x
	local s = lerp(0, 0.5, x)
	
	Blur.Size = lerp(0, 24, x)
	Wheel.Size = UDim2.new(s, 0, s, 0)
	Wheel.Visible = x > 0.1
end

-- Init

RBackpack.Parent = LOCALPLAYER.PlayerGui
Blur.Parent = LIGHTING

BackpackRadial:Show(Status)
local added
local removed
LOCALPLAYER.CharacterAdded:Connect(function(character)
	if (LOCALPLAYER.PlayerGui:FindFirstChild("TouchGui")) then
		return
	end
	
	Tools = LOCALPLAYER.Backpack:GetChildren()
	STARTERGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	BackpackRadial:Rebuild()
	added = LOCALPLAYER.Backpack.ChildAdded:Connect(function(c)
		if (LOCALPLAYER.PlayerGui:FindFirstChild("TouchGui")) then
			return
		end
		if c.Parent ~= character then
			Tools = LOCALPLAYER.Backpack:GetChildren()
			STARTERGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
			BackpackRadial:Rebuild()
		end
	end)
	removed = LOCALPLAYER.Backpack.ChildRemoved:Connect(function(c)
		if (LOCALPLAYER.PlayerGui:FindFirstChild("TouchGui")) then
			return
		end
		Tools = LOCALPLAYER.Backpack:GetChildren()
		STARTERGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		BackpackRadial:Rebuild()
	end)
	character:WaitForChild("Humanoid"):GetPropertyChangedSignal("Health"):Connect(function()
		if character:WaitForChild("Humanoid").Health <=0 then
			added:Disconnect()
			removed:Disconnect()
		end
	end)
end)
CONTEXT:BindAction("ShowBackpack", function(action, state, input)
	if (state == Enum.UserInputState.Begin) then
		BackpackRadial:OnOpen()
	elseif (state == Enum.UserInputState.End) then
		BackpackRadial:OnClose()
	end
end, false, Enum.KeyCode.Q, Enum.KeyCode.ButtonL1)

--MOBILE BUTTON CODE

local mbutton = LOCALPLAYER.PlayerGui:WaitForChild("ToolWheelUI").ToolButton
local open = mbutton.Parent.Open
mbutton.MouseButton1Click:Connect(function(input, gameProcessedEvent)
	if not gameProcessedEvent then
		if open.Value == false then
			
			BackpackRadial:OnOpen()
			
			print(Wheel)
			print(Wheel.ClassName)
			
			open.Value = true
		elseif open.Value == true then
			BackpackRadial:OnClose()
			open.Value = false
		end
	end
end)


RUNSERVICE.RenderStepped:Connect(function(dt) 
	BackpackRadial:OnStep(dt)
end)

Fixed issue by creating a separate Mobile RadialBackpack GUI.

2 Likes

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