"Dual Render" Scope System

Ohhh

Well, we can apply this same method the the ScreenPart instead of the CameraPart!

If the ScreenPart isn’t visible, then make the entire scope GUI not visible!

Ahhhh, never make the gun CanCollide. You will fling 99.999999% of the time.

Yup! That’s why I didn’t go with that!

Decided to update my example place with some nicer touches.

  • Scope fades out when unaimed (also made it only update when not faded, so it doesn’t eat CPU when unaimed)
  • Blur effect fades rather than appears
  • Added dirty glass texture over the scope
  • Added lighting effects for fun
External Media
3 Likes

Would you have a download for those updated touches?

Some are specific to my FPS system, so no.

To do the performance saving when unaimed, it’s a simple if statement.

PartUpdater = Heartbeat:Connect(function()
	if ViewPort.Visible and ViewPort.ImageTransparency~=1 then

I get an error involving a Primary Part when I try to use the script as is. The error is as follows:

RunService:fireRenderStepEarlyFunctions unexpected error while invoking callback: Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.

This is the only error I get. I tried setting the guns primary part in the script but I had no success.

This is super neat. If ViewportFrames could be non-square, it might be possible to create a Depth of Field effect with this. Excellent work!

2 Likes

I think I have a way to be able to optimise it a bit more.
If you only render/update items then are in view.
I’m pretty sure this is possible, but not 100%.
It is a great read and I will be using this and a setting for people.

Could this be transformed into a magnifying glass?

Yes it could probably work with a magnifying glass, but it would not be suitable for a real game environment like they said.

1 Like

I keep getting this error,
09:44:20.165 Model:SetPrimaryPartCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this. - Client - ViewportCameraController:47

I don’t know how to fix it :pensive:

This error is telling you that there is no set primary part for the model. Make sure to check if the model does have a primary part by looking at its properties, and if so then make sure nothing is setting it to nil. It may be getting destroyed as well.

How would I set the correct primary part? I know how to set one but I don’t know which part to set it as…

hmm I downloaded the world and tried it. I see what you mean now! For some reason the cloned model of the gun does not have a primary part set, so we will have to edit the script a little to make it so it does. Sure enough, it worked! All you have to do is go into: StarterGui > ScreenGui > DualRender > and open the script called “ViewportCameraController.” Make a line above line 47 and copy and paste this into it:

GunModel.PrimaryPart = GunModel.AimPart

It should be working now! Let me know if you have more trouble.

3 Likes

I’ll check it tomorrow. Thanks for your help!

i wonder if the demo works properly on mobile. i can launch the demo world just fine, just can’t aim down the scope.

I added the change you suggested, worked fine in the sense the scope works fine now, granted I cannot aim and the night vision overlay is on top of the gun. No errors now at least, but not working as the demo place.

For some reason mine is broken.

hey dude this work will be fantastic if you add like a portal camera like what egomoose added in this topic:Re-Creating a Portal Effect,