#Part that makes your camera shake/distort when looking at it

1 messages · Page 1 of 1 (latest)

eternal valve
#

Hmm

#

i can help you

novel ingot
#

There’s this property in the camera to see where it’s looking at. You could use that to check if the player is looking at a certain part/area

novel ingot
cobalt rampart
eternal valve
#

yea dude

cobalt rampart
#

True, dont expect to create scripts

eternal valve
#

but guy needs help

#

so i'll help him 🙂

#

`-- Put this script in a part that you want the player to look at

local targetPart = script.Parent -- The part that the player needs to look at
local shakeIntensity = 0.2 -- The intensity of the camera shake
local shakeSpeed = 10 -- The speed of the camera shake
local shakeDuration = 0.5 -- The duration of the camera shake

function shakeCamera()
local camera = game.Workspace.CurrentCamera
local shakeTimer = shakeDuration

while shakeTimer > 0 do
    local shakeAmount = shakeIntensity * shakeTimer
    local shakeOffset = Vector3.new(
        math.sin(time() * shakeSpeed) * shakeAmount,
        math.cos(time() * shakeSpeed * 2) * shakeAmount,
        math.sin(time() * shakeSpeed * 3) * shakeAmount
    )

    camera.CFrame = camera.CFrame + shakeOffset
    wait()
    shakeTimer -= wait()
end

end

function onRenderStepped()
local camera = game.Workspace.CurrentCamera
local ray = Ray.new(camera.CFrame.p, camera.CFrame.LookVector * 100)
local hitPart, hitPosition, hitNormal = game.Workspace:FindPartOnRay(ray)

if hitPart == targetPart then
    shakeCamera()
end

end

game:GetService("RunService").RenderStepped:Connect(onRenderStepped)`

cobalt rampart
#

Tell him how to do it, but let him script it

#

Why do I feel likr thats chat gpt?

eternal valve
#

propably

#

the look vector thing

#

only

#

cause thats a bit confusing lol

eternal valve
#

K

#

Wait sir

eternal valve
#

oh m god y