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

How do I get the speed of a player, not walk speed but just the overall speed?

Asked by 4 years ago

I'm not great with scripting but I'm wondering how I can continuously grab the speed of a player. This does not refer to walk speed but just the speed/magnitude of a player. For example, constantly grabbing the speed of a player throughout a roller coaster ride or a bus ride. The point of this is to convert that to a player's local field of view, to create a dramatic speed effect.

while true do
    wait()
    local player = game.Players.PlayerAdded:Connect()
    player.Humanoid.HumanoidRootPart = game.Workspace.Camera.FieldOfView
end

I know that if this were to work the field of view would be weird, but I'm looking for a starting point (I'll add different values later to make it work properly)

3 answers

Log in to vote
0
Answered by 4 years ago

Try checking the players velocity maybe?

0
I know but how do I do that? TheBeaver101 28 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

There is an event of the Humanoid called Running. It basically fires every time the player's velocity changes and has a parameter with how many studs per second they are moving.

Humanoid.Running:Connect(function(Speed)
    -- ok
end)
0
What do I put in the middle? Also, it tells me Humanoid is an unknown global yet i can't call it out. game.Players.LocalPlayer.Humanoid is not possible. TheBeaver101 28 — 4y
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
4 years ago

As CowboySprite said, you'd need to check their Velocity. Below will get the job done:

print(game.Players.LocalPlayer.Character.Head.Velocity.Magnitude)
0
That doesn't work. I'm in studio play mode and there is no LocalPlayer.Character.Head, it says I'm trying to "index a nil with 'Character'" TheBeaver101 28 — 4y

Answer this question