-
What do you want to achieve? Keep it simple and clear!
I’m making a gun system and i need to cast a ray towards specific point from position of the screen
I need to get a Position of camera after turning on shiftlock on local script -
What is the issue? Include screenshots / videos if possible!
Camera Position does not update for scripts when turning on shiftlock
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried using workscape.Camera, workspace.CurrentCamera, nothing works, couldn’t find anything related on the forums
-- Local script:
warn("Local Script camera Position: "..tostring(workspace.CurrentCamera.CFrame.Position))
-- Command Bar:
warn("Command Bar camera Position: "..tostring(workspace.CurrentCamera.CFrame.Position))
It’s completely the same but for some reason local script does not get updated CFrame of camera when enabling shiftlock
local script context:
local Position = Camera:ViewportPointToRay(Camera.ViewportSize.X/2,0+Camera.ViewportSize.Y/4,2000)
local rparams = RaycastParams.new()
rparams.FilterType = Enum.RaycastFilterType.Exclude
rparams.FilterDescendantsInstances = {game.Players.LocalPlayer.Character}
local ogpos = Camera.CFrame.Position
local result = workspace:Raycast(workspace.CurrentCamera.CFrame.Position,Position.Unit.Direction*2000,rparams)
warn("Local Script camera Position: "..tostring(workspace.CurrentCamera.CFrame.Position))