Hey Devs,
Im making a FieldOfView effect for mobile players. If they move fast enough, the field of view will zoom out. To get the players current speed you sadly can’t use the Humanoid.MoveDirection.Magnitude function because it only goes from 0 to 1. You also can’t use the WalkSpeed of the Humanoid since on Mobile, if you have a dynamic thumbstick, you can variate with your speed. So my question is how to check for the current players speed. Since on computer pressing W (going forwards) you always go instantly as fast as your Walkspeed is this function only works for mobile.
Any help would be appreciated, thanks!
you can use AssemblyLinearVelocity.Magnitude
example:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAppearanceLoaded:Connect(function(char)
while true do
print("Plr Speed: ", char.PrimaryPart.AssemblyLinearVelocity.Magnitude)
task.wait(2)
end
end)
end)
if you want it as an integer use math.round
I tried the script in studio and it printed that AssemblyLinearVelocity is nil to character… (also sorry for marking it for the solution before, i put the lines in a disabled script)
EDIT: got it to work by changing the primarypart to the torso of the player
it is also very easy if you just multiply the direction magnitude by the walkspeed.