Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Could someone help with this camera script? [Solved]

Asked by 5 years ago
Edited 5 years ago

So basically, I have this script which sends out a raycast from the player's torso to the position of their camera. The point of this script is to make a part that the player's camera touches go semi-transparent so they can look through it, and then go back to the transparency it was before when they move their camera away. If you still don't know what I mean, here's a video (sorry it's fuzzy). This is what I have so far:

local rs = game:GetService("RunService")

local plr = game:GetService("Players").LocalPlayer

workspace:WaitForChild(plr.Name)

function render()
    local ray = Ray.new(plr.Character.UpperTorso.CFrame.p, (workspace.CurrentCamera.CFrame.p - plr.Character.UpperTorso.CFrame.p).Unit * 300)
    local part, position = workspace:FindPartOnRay(ray,plr.Character,false,true)
    if part then
        part.Transparency = 0.5
        wait()
        part.Transparency = 0
    end
end

rs.RenderStepped:Connect(render)

There are a few problems with this script: the camera isn't able to go through the object since the transparency is constantly being changed, and if the object had a different transparency-such as 0.3-to begin with, it would be set back to a transparency of 0 after the player moved their camera away. If you know what I should add to the script, have a suggestion, or think I should go about this a different way altogether, then please let me know.

0
Make the camera nocollide. Don't know if it'll work, but worth a try. kittonlover101 201 — 5y
0
Didn't really understand but I believe you could try setting the DevCameraOcclusionMode to Invisicam in the StarterPlayer service. Sound like it to me. Y_VRN 246 — 5y
0
Thanks! Didn't realize you could just do that. Endergenius100 12 — 5y

Answer this question