Code Somehow Removing Mobile Joystick and Jump Button?

So I am having a very large problem, that I have no idea how to fix.

Once implementing the code, I noticed that part of the mobile interface had disapeared, only the JumpButton and Joystick. (ALSO… the joystick and jumpbutton only disapears when in the Roblox Player not in the Roblox Studio Player)

After moving UIs back and forth from StarterGUI to ServerStorage to find out what caused this random problem, I found this script:

local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = game.ReplicatedStorage:WaitForChild("SpawnCar")
local DeleteCarEvent = game.ReplicatedStorage:WaitForChild("DeleteCar")
local CarParams = game.ReplicatedStorage:WaitForChild("GetCarParams"):InvokeServer(script.Parent.Name)
local carName = script.Parent.Name

script.Parent.CarName.Text = CarParams.Name

local CarImage

for i, v in pairs(game.Players.LocalPlayer.PlayerGui.DealershipScreen.CarLibrary.Sections:GetDescendants()) do
	if v:IsA("ViewportFrame") and v.Name == script.Parent.Name then
		CarImage = v.CarImage
	end
end

local clonedCarImage = CarImage:Clone()
clonedCarImage.Parent = script.Parent
clonedCarImage.Position = UDim2.new(0.5, 0, 0.5, 0)
clonedCarImage.AnchorPoint = Vector2.new(0.5, 0.5)
clonedCarImage.Size = UDim2.new(1, 0, 1, 0)
clonedCarImage.ZIndex = 31
clonedCarImage.Name = "CarImage"

script.Parent.MouseButton1Down:Connect(function()
	
	script.Parent.Parent.Parent.Parent.Parent:TweenPosition(UDim2.new(0.5,0,-1.5,0),Enum.EasingDirection.In,Enum.EasingStyle.Back,1,true);
	script.Parent.Parent.Parent.Parent.Parent.IsOpen.Value = false
	
	local CurrentCar = game.Workspace:FindFirstChild(player.Name .. "sCar")
	if not CurrentCar then
		SpawnCarEvent:FireServer(carName)
	else
		for i, v in pairs(CurrentCar:GetDescendants()) do
			if v:IsA("VehicleSeat") or v:IsA("Seat") then
				if v.Occupant and v.Occupant:IsA("Humanoid") then
					v.Occupant.Sit = false
				end
			end
		end
	wait()
	DeleteCarEvent:FireServer(CurrentCar)
	SpawnCarEvent:FireServer(carName)
	end
end)

then, I managed to confine it down to this part to find out what was causing it:

for i, v in pairs(game.Players.LocalPlayer.PlayerGui.DealershipScreen.CarLibrary.Sections:GetDescendants()) do
	if v:IsA("ViewportFrame") and v.Name == script.Parent.Name then
		CarImage = v.CarImage
	end
end

Of which i found out that if I delete the if then statement, the joystick and jump button come back.

However, I have no idea at all how this could be occuring. Everywhere I look I can’t find a solution and everyone I ask have no idea how or why this is happening, and I can’t see what is occuring to the Joystick and JumpButton since it doesn’t happen in Roblox Studio, but only on mobile. Why is this occuring?

2 Likes

it’s probably because of StarterGui:SetCoreGuiEnabled() though i cannot find it in the script you provided

maybe it’s on another script, try pressing Ctrl+Shift+F then type SetCoreGuiEnabled() to check if there are any scripts that uses it

also dont move anything from StarterGui to ServerStorage because anything from the client cannot access the server and etc.

that’s why your script errors: it tries to get Players.LocalPlayer and use the function InvokeServer() when the client can only do that and not the server

it’s best you check this out

Yes, I know how it works. The point of moving it there was so then it wouldn’t work, so then I could figure out what was causing it not to work. Basically the equivalent of me deleting it.

Yeah, oddly enough I couldn’t find that command anywhere in the game. I already had searched before to see if it was anywhere.

(replied to the wrong comment)

Solved the problem by just working around and restructuing the script. Still have no idea how this happened…

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