Any help to make a mobile badge?

Ive tried to make a You Played On Mobile Badge! but it doesn’t work…

These are my scripts

Server Script

local mobileplayerevent = game.ReplicatedStorage.MobilePlayer
mobileplayerevent.OnServerEvent:Connect(function()
		local BadgeService = game:GetService("BadgeService")
	local id = 2124615024
		game.Players.PlayerAdded:Connect(function(plr)
			if not BadgeService:UserHasBadgeAsync(plr.UserId, id) then
				BadgeService:AwardBadge(plr.UserId, id)
		end
	end)	
end)

Local Script (StarterPlayerScripts)

local UserInputService = game:GetService("UserInputService")
if not 
UserInputService.KeyboardEnabled 
and not 
UserInputService.GamepadEnabled 
then
game.ReplicatedStorage.MobilePlayer:FireServer()
end
1 Like

The client script is great, but you need to modify the server script so that it works using the Player who fired the event.

You may also want to use WaitForChild to yield for the event as a safety precaution.
Example:

local mobileplayerevent = game.ReplicatedStorage:WaitForChild("MobilePlayer")
mobileplayerevent.OnServerEvent:Connect(function(plr) --the player argument is automatically passed
	local BadgeService = game:GetService("BadgeService")
	local id = 2124615024
		
	if not BadgeService:UserHasBadgeAsync(plr.UserId, id) then
	    BadgeService:AwardBadge(plr.UserId, id)
	end

end)
2 Likes

I could just unplug my keyboard and get the badge, FWIW. There’s no great method for checking what console somebody’s on.

3 Likes

Thanks! I will try it now!

It Worked!!! Thanks so much!

2 Likes