I Am Trying To Check If A User Has A VR Device Connected
My :InvokeClient() Won’t Return, The Client Prints But The Server Does Not, I Haven’t Used Remote Functions Before So I Don’t Know How To Fix This.
The Server Script Is In StarterGUI, The Client Script And Remote Function Are Parented To The Server Script
Server Script:
--==========Locals==========--
local Event = script:WaitForChild("IsVR")
local Plr = script.Parent.Parent
--==========Main==========--
Plr.CharacterAdded:Connect(function()
local IsVR = Event:InvokeClient(Plr)
if IsVR then
print("Player Is Using Virtual Reality")
else
print("Player Is A Normal Person")
end
print("Done")
end)
--====================KeithKeiser971====================--
Local Script:
--==========Locals==========--
local Plr = game.Players.LocalPlayer
local VRService = game:GetService("VRService")
local Event = script.Parent:WaitForChild("IsVR")
--==========Main==========--
Event.OnClientInvoke = function()
if VRService.VREnabled then
print("True")
return true
else
print("False")
return false
end
end
--====================KeithKeiser971====================--
The Output Prints “False” From The Client But The Server Doesn’t Print Anything.
--==========Locals==========--
local Plr = game.Players.LocalPlayer
local VRService = game:GetService("VRService")
local Event = script.Parent:WaitForChild("IsVR")
--==========Main==========--
local function IsVR()
if VRService.VREnabled then
print("True")
return true
else
print("False")
return false
end
end
Event.OnClientInvoke = IsVR
--====================KeithKeiser971====================--
Event.OnClientInvoke = function()
if VRService.VREnabled then
print("True")
return true
else
print("False")
return false
end
print("Will return") -- Here
end
--==========Locals==========--
local Plr = game.Players.LocalPlayer
local VRService = game:GetService("VRService")
local Event = script.Parent:WaitForChild("IsVR")
--==========Main==========--
Event.OnClientInvoke = function()
if VRService.VREnabled then
print("True")
return true
else
print("False")
return false
end
print("Will return") -- Here
end
--====================KeithKeiser971====================--
It Prints Something-Server And False-Client, But Doesn’t Print Will Return, Also In Studio It Is Marked As Unreachable Code