I'm trying to use the Roblox default code for VREnabled and UserInputService and it works just how I want it to until you die. Once you reset, your character will no longer move its head to where you're looking. Here is the normal code:
local UserInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local function TrackHead(inputType, value)
if inputType == Enum.UserCFrame.Head then
head.CFrame = value
end
end
if UserInputService.VREnabled then
-- Set the inital CFrame
head.CFrame = UserInputService:GetUserCFrame(Enum.UserCFrame.Head)
-- Track VR headset movement and mirror for character's head
UserInputService.UserCFrameChanged:Connect(TrackHead)
end
I tried fixing this by checking when the player died but had no luck. example:
local UserInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local function TrackHead(inputType, value)
if inputType == Enum.UserCFrame.Head then
head.CFrame = value
end
end
if UserInputService.VREnabled then
character.Humanoid.Died:Connect(function()
-- Set the inital CFrame
head.CFrame = UserInputService:GetUserCFrame(Enum.UserCFrame.Head)
-- Track VR headset movement and mirror for character's head
UserInputService.UserCFrameChanged:Connect(TrackHead)
end)
end
I'm trying to make a game similar to this. But I'm having trouble understanding how to use all this since there aren't many tutorials other than the Roblox developer page. I'd appreciate any links you can send me or ways to fix this.

1 comment
I don't really know how to make a vr game on roblox, but I think it has to do with that you have to wait for the character to respawn.