Multiple errors in VRService.UserCFrameChanged code sample

The code example on this entry to the hub

local VRService = game:GetService("VRService")
     
VRService.UserCFrameChanged(function(type, value)
    print(type.Name + " changed. Updated Frame: " + value)
end

The flaws in this code example

  • Performing arithmetic on strings
  • Completely forgetting to add :Connect
  • Failing to close the conclusive end with a )
  • Names an argument / variable ‘type’
13 Likes

Is there a correct version available anywhere? I’ve been trying to get this to work for a while now but without much luck. The somewhat updated one in the hub still returns errors and still tries to perform arithmetic on strings.

1 Like
-- We must get the VRService before we can use it
local VRService = game:GetService("VRService")

-- A sample function providing one usage of UserCFrameChanged
local function userCFrameChanged(typ, value)
print(typ.Name, " changed to: ", value)
end

VRService.UserCFrameChanged:Connect(userCFrameChanged)

I actually found the solution myself so if anyone needs it here it is.

1 Like

This code sample still seems to be on this page after two years. A response from Roblox Staff would be appreciated.

2 Likes

Should be resolved now, thanks for the report!

3 Likes

This topic was automatically closed after 8 days. New replies are no longer allowed.