In my game, I want a sound to play when you are put in FPS mode, but I need to know how it would sound only at that point, does anyone have any idea how this would work? I know you wouldn't use FieldOfView becuase that changes everything around... Can anyone please help me?
✓ ANSWER ACCEPTED
I need help on camera manipulation, have any idea?
1 answer
✓ Accepted answer
The best way to do this is check the distance between the CurrentCamera and the Head. I would use magnitude for this like so
local Magnitude = (CurrentCamera.CoordinateFrame.p - Head.CFrame.p).magnitude
Usually the magnitude is around 1 stud when you are zoomed into first person.
if Magnitude <= 1 then
-- do stuff()
end
To make this work though, you would have to put this in a while loop because I'm pretty sure .Changed doesn't fire for CoordinateFrame. Also, to make your sound only run when you get put in first person, we can make a variable named ZoomedIn and if it is already true than not play the sound.
local ZoomedIn = false
while true do
wait(.01)
local Magnitude = (CurrentCamera.CoordinateFrame.p - Head.CFrame.p).magnitude
if Magnitude <= 1 and ZoomedIn == false then
-- sound stuff
ZoomedIn = true
else
ZoomedIn = false
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Thank you, I nknow how to do the rest, I just needed help to find the one property, thank you.
why is there a either A missing parentheses, or B, extra parenteheses?
Woops I accidentally put parenthesis after .magnitude. I'll edit the post
Thanks, i was a bit confused...
Also, instead of it being a variable, I just did an elseif statement instead of just an else