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

Acceleration Counter Script | One-Second Delay on player's Velocity.magnitude?

I wanted to make an acceleration counter that shows the player's acceleration especially when falling or speeding up. I was thinking of having the player's Velocity.magnitude minus the Velocity.magnitude 1 SECOND AGO. This requires me to add a delay of 1 second on a while loop. Is there a way to delay the Velocity.magnitude reading by 1 second after the player moves?

math.randomseed(tick())
wait()

boop = game.Players.LocalPlayer
if boop.Character then
player = boop.Character
end


while true do			
	a = math.floor((((player.Head.Velocity.magnitude)-(--[[Velocity 1 second ago]])*2)*100))/100
	script.Parent.Text = a .. " studs/s^2"
	wait()
end 

1 answer

Something like...

repeat wait() until game.Players.LocalPlayer.Character

game.Players.LocalPlayer.Character.Changed:connect(function()
	wait(1)
	a = math.floor((((player.Head.Velocity.magnitude)-(--[[Velocity 1 second ago]])*2)*100))/100
	script.Parent.Text = a .. " studs/s^2"
end)

...?

1 comment

0

The script is what gives the value of the acceleration to the text which displays the acceleration. Basically I need a separate script that should take the Velocity.magnitude of the player 1 second ago. In other words, a 1 second delay of the Velocity.magnitude. Then in line 5, it's just the formula that subtracts the current Velocity.magnitude to the delayed Velocity.magnitude.

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