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

Making a car A.I, need help with math? (Solved)

Hello Im making a A.I car system and im making it stop at stop lights and stop signs at the moment, everything works fine it is just, let me explane

The car will take exactly 1 second to go from the speed it is at now to 0 Now i want to know how do i work out how far away the car must be form the stop sign/stoplight before slowing down Can somebody please help

here is what i got

---Alot of other code
local Amount = script.Parent.Humanoid.WalkSpeed - 20
if Amount < 20  then
  Amount = 20
elseif Amount >= 70 then
  Amount = 70
end
        if (c.Position - script.Parent.SpeedControlPart.Position).Magnitude <= Amount and c.Stop.Value == true then
---Alot of other code

1 answer

That wil be easy, make

amount = script.Parent.Humanoid.WalkSpeed / 2 + 10 ---  script.Parent.Humanoid.WalkSpeed will be the car's speed

then let it go foawrd untill it get to the place it must stop fully

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