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

Anybody here a mathematician?

Hi. I have two players & 1 target. Im basically trying to make both of them reach the target at the exact same time.

player 1 is traveling 16 studs per second & is 20 studs away from the target

player 2 is 120 studs away from the target

does anybody know what walk speed Player 2 needs to travel at to reach the target at the exact same time as player 1?

1 answer

✓ Accepted answer

Oh boy, I'm not a mathematician, not yet!

There is some simple algebra to use here. Let's step through it and implement it in a script.

we are given the speed of player 1. v1 = velocity of player 1 (well the magnitude of his velocity)

we are given three positions p1, p2, pt = position of player 1, position of player 2, position of target and therefore displacements (differences in position) d1, d2

we will leave time unknown because we don't care about, this means we will substitute to get rid of it in our equations in just a second

velocity is given by distance divided by time
v1 = d1/t
v2 = d2/t

t = d1/v1
v2 = d2/(d1/v1)

cool!

Now let's do this in a script.

local player1
local player2

local walkspeed1 = player1.Character.Humanoid.WalkSpeed
local position1 = player1.Character.Torso.Position
local position2 = player2.Character.Torso.Position

local target = Vector3.new(0,0,0) -- Just an example

player2.Character.Humanoid.WalkSpeed = (position2 - target).Magnitude / ( (position1 - target).Magnitude / walkspeed1 )

I answered this question with a script that describes how you would do it in any scenario. To answer your specific question.

v2 = 116 / ( 20 / 16) = 92.8 studs per second

2 comments

1

thank you

0

Maybe a little bit late, however the equation you would set up should be - 20/16 = 120/x, x would be 96, so 96 studs per second.

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