Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

Try checking the players velocity maybe?

1 comment

0

I know but how do I do that?

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)

1 comment

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.

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

print(game.Players.LocalPlayer.Character.Head.Velocity.Magnitude)

1 comment

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'"

This discussion is preserved as it was. New answers, comments, and votes are closed.