|
So I have a script that subtracts two vector3 positions to get the amount of studs between point A and point B. How do I change the Vector3 coordinate that prints to a single number.
Script:
while true do
A = game.Workspace.Car.something.Position
wait(1)
B = game.Workspace.Car.something.Position
Speed = A - B
print(Speed)
end |
|
|
|
|
i need help pls
--Who needs signatures-- |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
You could just get the Magnitude of the Velocity, but in your case just do print(Speed.Magnitude) |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Using .magnitude:
while true do
A = game.Workspace.Car.something.Position
wait(1)
B = game.Workspace.Car.something.Position
Speed = (B - A).magnitude
if (Speed < 0) then
Speed = Speed * -1
end
print(Speed)
end
I would also suggest reducing the wait time. A speedometer that only updates once per second doesn't seem too useful. |
|
|
I am going to make it every .01 seconds and then just multiply by 100. Also I have another question. How do I make it where you can be in first person in a vehicleSeat? |
|
bibo5oJoin Date: 2009-01-17 Post Count: 414 |
source --https://scriptinghelpers.org/questions/5/how-do-i-force-first-person-mode
Put this in a Touched() function
player.CamerMode = Enum.CameraMode.LockFirstPerson
When they get off I think there is a connectionEnded() event as well, not sure.
player.CameraMode = Enum.CameraMode.Classic |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Seat.ChildAdded event |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
A weld object is created and parented to the seat when a player sits in it. The weld disappears when the player leaves the seat. Using ChildAdded (as said above) you can do what you need.
Also, for forcing first person:
game.Players.Player.CameraType = "LockFirstPerson" |
|
|
Ok so how do I round the speed? Theres like a million digits. |
|
|
In other words how do I round? |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
An easy way to round would be to just use math.floor(num) on the number which will basically just get rid of all the decimals without really rounding. Do you want the speed to just be whole numbers, or do you want some decimals? |
|