Hello.
I am trying to make a speedometer for my plane, and want to create a value that will be updated constantly with the current speed relative to the ground. Here is my current code:
local Velocity = MainPlane.Nose.Velocity.Magnitude
while Enginevalue == 1 do
Velocity = MainPlane.Nose.Velocity.Magnitude
SpeedUI.SpeedTextIndicatorGUI.Text = ('Speed ' ..Velocity.. ' knots')
task.wait()
end
When the plane is spawned in, the value is at zero, however when I start moving, the value remains at zero instead of changing.
Engine value is needed here, as I need it to be active when it is equal to one. I also tried the while true do script separately, however that did not work either.
Tried this as well, but it did not work. I did find the solution myself just now by combining the entire script with the enginevalue function. Neither the less, thank you for your help, very much appreciate it.
local mainplane = game.Workspace:WaitForChild("MainPlane",10)
local Velocity = 0
local EngineValue = 1
local nose
if mainplane ~= nil then
nose = mainplane:WaitForChild("Nose",8)
if nose ~= nil then
while EngineValue == 1 do
Velocity = nose.Velocity.Magnitude
SpeedUI.SpeedTextIndicatorGUI.Text = ('Speed ' ..Velocity.. ' knots')
task.wait(.1)
end
end
end
I tried something similar with no issues. Place both scripts in startercharacter:
localscript 1 makes the nose part:
local char:Model = script.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local SpeedUI = player.PlayerGui:WaitForChild("SpeedUI",10)
local Velocity = 0
SpeedUI.SpeedTextIndicatorGUI.Text = ('Speed ' ..Velocity.. ' knots')
local nose = workspace:WaitForChild("Nose",8)
for x = 2, 0, -1 do
warn("Countdown = ".. tostring(x))
task.wait(1)
end
warn("Drop!")
nose:PivotTo(CFrame.new(0,300,-16))
while true do
Velocity = nose.Velocity.Magnitude
SpeedUI.SpeedTextIndicatorGUI.Text = ('Speed ' ..Velocity.. ' knots')
task.wait(.1)
end