Scripts working on PC but not Mobile

Here’s the deal. I’m doing fixes for Mobile Support in my badge hunting game, and I have gears that are given to the player if they own a certain badge. When I load up the game on PC with the badges owned the gears are moved into my inventory. When loading up the game on Mobile however, no gears are moved into my inventory. Furthermore I have gears in my game you can click to pick up into your inventory and those don’t work on Mobile either. Here is one of the scripts for Badge Gears. Does anyone know why this script doesn’t work on Mobile?

local badgeService = game:GetService(“BadgeService”)
local gear = {
game.Lighting.TixGun;
}

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function()
if badgeService:UserHasBadgeAsync(plr.UserId, 2124853219) then
for i,v in pairs(gear) do
print(v.Name)
v:Clone().Parent = plr:WaitForChild(‘Backpack’)
end
end
end)
end)

2 Likes

The script that gives tools when they respawn should work fine, the ones where you can click to pickup however are probably the problem. If you give me the code for those, I can try to fix it for you.

1 Like

do you get any errors, and is the name of the tool printed?

1 Like

Here ya go:

script.Parent.ClickDetector.MouseClick:Connect(function(player)

if player then
	
	if player.Backpack:FindFirstChild("TombKey") then 
		
		return
		
	else
		
		local Copy = game.Lighting.TombKey:Clone()
	
	Copy.Parent = player.Backpack
	end
	
	
	
	
end
end)
1 Like

the name of the tool is printed and no there are no errors

Odd. Does this happen in studio on mobile testing mode, or only on mobile ingame? Also, can you verify that the inventory gui is not being disabled for mobile players? (Do ctrl+shift+f and search for SetCore. Also check if the tools are being parented to the player’s backpack).

1 Like

Mobile ingame is what I’ve tested, I havent tried mobile testing mode in sudio

1 Like

Also I know the inventory is not disabled because theres a lantern everyone spawns with ingame and I can see that

1 Like

Quite odd. I couldn’t find anything wrong with your code. If you were able to verify that the tools weren’t able to be parented to the player’s backpack, you could try parenting the tools once to the player’s StarterGear, a built in feature that allows a character to spawn with tools.
Example code:

local badgeService = game:GetService("BadgeService")
local plrs = game:GetService("Players")
local gear = {
	game.Lighting.TixGun;
}

plrs.PlayerAdded:Connect(function(plr)
	if badgeService:UserHasBadgeAsync(plr.UserId,2124853219) == false then return end
	
	local starterGear = plr:WaitForChild("StarterGear")
	for i,v in pairs(gear) do
		print(v.Name)
		v:Clone().Parent = starterGear
	end
end)

If the tools were successfully parented to the player’s backpack, and the inventory is enabled, I don’t really know how to solve this problem.

1 Like

Kind of a random guess but I think Roblox Mobile is limited to 3 items in the hotbar? (Not too sure though, but that is how it is in my game for some reason and I don’t think I changed any settings) Do you think that maybe they are in your backpack and not in the hotbar?

I got my mobile friend to join the game and her gears worked, so it must be something with my phone. I tried reinstalling roblox and it still doesnt work for me. Im gonna find some other mobile users to help test this out

Have you tried in studio mobile emulator thingymabob?