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

Have the player jump towards position?

Asked by
2_MMZ 1059 Moderation Voter
3 years ago

This is another part for my survival game! I've figured out what I've needed, the player holding the curtains, and detecting if they're facing at it or not! The only thing left to do is when they press the Spacebar, the player jumps towards the position they're facing at. I have a bit of code for this such as

if mouse.Target == game.Workspace.facingright then
      UIS.InputBegan:Connect(function(input, gameProcessedEvent)
             if input.KeyCode == Enum.Keycode.Space then
                     --jump code would go here.
              end
      end)
end

As I don't know how to start where the player jumps towards the position. I've made many attempts for this such as having the player's camera be stationary, but still able to be rotated, (like first person.) I've disabled the player jumping manually, as the script makes them get closer to the position they're facing. But I still can't seem to figure this out.

Can anyone help me on this? Thanks! Any working answer is appreciated, thanks!

2 answers

Log in to vote
1
Answered by 3 years ago

What I would do is tween the seat.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
Humanoid.Jump = true
Humanoid:MoveTo(position player is facing)

This? Hope it helps :P

Edit:

To move the camera to a position use cframe. Cframe.new() I think has 6 different parameters group choices meaning there's 6 types of cframe formatting things and the one that makes anything face toward a position is cframe.new(position, position2) position being the position of the instance and position2 being where the instance faces, and its not a relative position, it's world position meaning if you do 0,1,0 for position2 and let's say the instance (the camera of course) is rotated to look down so it's up is actually forward, then it would still go up, because it's not relative to the camera, it's relative to the world, so it would still go 0,1,0 which is a stud up.

Like this I think

Camera.CFrame = CFrame.new(Camera.Position, LookatPos)

I hope this is what you need, if not, I'll help again

0
I appreciate this answer so much! However, I should've been more specific. What I'm looking for is that the players camera moves towards the position they're facing. 2_MMZ 1059 — 3y
0
Then use cframe, hold on ill update my answer and if its also not what your looking for then ill fix it until you get ur answer AlexanderYar 788 — 3y

Answer this question