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

How do you lower the players camera when pressing a key?

Asked by 5 years ago
Edited 5 years ago

I am trying to make a crouch script for a fps. The camera is supposed to move down and up depending if they are crouching or not.

01mouse.KeyDown:Connect(function(key)
02    if key == "c" and crouching == 1 then
03    crouching = 2
04    h.WalkSpeed = h.WalkSpeed - 15
05    h.JumpPower = h.JumpPower - 60
06    playAnim:Play()
07    cam.CFrame = cam.CFrame - Vector3.new(0,5,0)
08    script.Parent.CrouchNonfication.Text = "Crouching"
09    crouching = 3
10    elseif key == "c" and crouching == 3 then
11    crouching = 2
12    h.WalkSpeed = h.WalkSpeed + 15
13    if p.Perk.Value == "Kangaroo" then
14    h.JumpPower = 60
15    else
View all 24 lines...
1
Correct me if I'm wrong, but doesn't the camera need to be in "Scriptable" in order to be changed by a script? beeswithstingerss 41 — 5y
0
you may he on to something ReallyUnikatni 68 — 5y
0
Did that ever fix it? beeswithstingerss 41 — 5y
0
rip i forgot ill do it rn ReallyUnikatni 68 — 5y
View all comments (2 more)
0
yeah! youre right ReallyUnikatni 68 — 5y
0
nvm now it stays there ReallyUnikatni 68 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

One way you can do it is by setting the camera to a part that you can easily use CFrame on. PeasFactory offers a really good explanation of this that you can find here. Another way would just to keep the camera locked onto the head, which should follow your crawling animation

0
If you do have any further questions about how this would work, feel free to message me on roblox. beeswithstingerss 41 — 5y
0
the prob is that you need the player in first person ReallyUnikatni 68 — 5y
0
when setting it to the head it takes out the first person ReallyUnikatni 68 — 5y
Ad

Answer this question