Need help with plugin

So. Im making a load character type of plugin. And i have an option called “Load character at origin”. When its activated. You guessed it. It loads the character model at the origin. But i want the plugin to load the character model where the camera is facing if the option is deactivated.

This is my plugin code that loads the character model atm.

if LOAD_ORIGIN == true then
			DUMMY:SetPrimaryPartCFrame(CFrame.new(0, 3, 0))
			
			
		elseif LOAD_ORIGIN == false then
			local CAM = game.Workspace.CurrentCamera:ScreenPointToRay(game.Workspace.CurrentCamera.CFrame.p.X, game.Workspace.CurrentCamera.CFrame.p.Y)
			local rayParams = RaycastParams.new()
			rayParams.FilterDescendantsInstances = {}
			rayParams.FilterType = Enum.RaycastFilterType.Blacklist
			rayParams.IgnoreWater = true
			
			
			local RAY = game.Workspace:Raycast(CAM.Origin, CAM.Direction * 1000)
			if RAY then
				DUMMY:SetPrimaryPartCFrame(CFrame.new(RAY.Position.Z, RAY.Position.Y, RAY.Position.Z) + Vector3.new(0, 3, 0))
			end
		end

See this post maybe it could help you.

1 Like