"You Played in VR" Badge

I’m trying to add a badge to my game that detects and awards when someone joins the game in vr.
I’m basically a complete beginner at scripting, so I have no idea what’s wrong with the code (or which place I should even put it in the explorer)

this is the code

local VRService = game:GetService("VRService")                
local userInputService = game:GetService("UserInputService")  
local BadgeService = game:GetService("BadgeService")      
local Players = game:GetService("Players").LocalPlayer           

local isUsingVR = userInputService.VREnabled                
if (isUsingVR) then
	BadgeService:AwardBadge(Players.UserId, 2144787942) 
end

if someone could help me out that would be great

The client (localscript) can not award a badge. Instead fire a remote event to award the badge on the server.

1 Like