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
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)