Hello everyone, im trying to make a plane with bodyvelocity but for some reson it doesn’t move.
Script:
local part = script.Parent.Parent.Main
local event = script.Parent.Plane
local bv = part.BodyVelocity
event.OnServerEvent:Connect(function(plr, running)
if running == true then
print("Moving")
bv.Velocity = part.CFrame.LookVector * 150
elseif running == false then
print("Not moving")
bv.Velocity = part.CFrame.LookVector * 1
end
end)
There are no anchored parts, for soem reason before when I was trying to do it by changing the part’s velocity the part moved, but I switched to bodyvelocity because according to the wiki it can give a constant speed. And now it doesnt move.
So these two scripts make the plane move, the first one makes it go straight and the second one lets it steer.
local part = script.Parent.Parent.Main
local event = script.Parent.Plane
event.OnServerEvent:Connect(function(plr, running)
if running == true then
print("Moving")
local i = Instance.new("BodyVelocity")
local c = Instance.new("BodyAngularVelocity")
c.Parent = part
i.Parent = part
i.Velocity = part.CFrame.LookVector * 150
i.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
elseif running == false then
print("Not moving")
part.BodyVelocity:Destroy()
part.BodyAngularVelocity:Destroy()
end
end)
local seat = script.Parent
SteerSpeed = 850
seat.Changed:Connect(function(p)
if p == "SteerFloat"then
local s = script.Parent.Parent.Main.BodyAngularVelocity
s.AngularVelocity = Vector3.new(0,-SteerSpeed*seat.SteerFloat,0)
end
end)
I first wanna get the main part done.
I have been trying ddifferent ways of updating the CFrame but all of them dont work or are bugged. How could I do it?
This is the current script im using:
local part = script.Parent.Parent.Main
local event = script.Parent.Plane
event.OnServerEvent:Connect(function(plr, running)
if running == true then
print("Moving")
local i = Instance.new("BodyVelocity")
local c = Instance.new("BodyAngularVelocity")
c.Parent = part
i.Parent = part
i.Velocity = part.CFrame.LookVector * 150
i.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
elseif running == false then
print("Not moving")
part.BodyVelocity:Destroy()
part.BodyAngularVelocity:Destroy()
end
end)
Edit:
Just tried this but it doesnt work:
local part = script.Parent.Parent.Main
local event = script.Parent.Plane
event.OnServerEvent:Connect(function(plr, running)
wait(0.2)
part.BodyVelocity:GetPropertyChangedSignal("Velocity"):Connect(function()
part.BodyVelocity.Velocity = part.CFrame.LookVector * 150
end)
end)
local part = script.Parent.Parent.Main
local event = script.Parent.Plane
event.OnServerEvent:Connect(function(plr, running)
if running == true then
print("Moving")
local i = Instance.new("BodyVelocity")
local c = Instance.new("BodyAngularVelocity")
c.Parent = part
i.Parent = part
i.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
elseif running == false then
print("Not moving")
part.BodyVelocity:Destroy()
part.BodyAngularVelocity:Destroy()
end
end)
local seat = script.Parent
SteerSpeed = 850
seat.Changed:Connect(function(p)
if p == "SteerFloat"then
local s = script.Parent.Parent.Main.BodyAngularVelocity
local bv = script.Parent.Parent.Main.BodyVelocity
s.AngularVelocity = Vector3.new(0,-SteerSpeed*seat.SteerFloat,0)
bv.Velocity = script.Parent.Parent.Main.CFrame.LookVector * 150
end
end)
This is what i meant when changing updating the velocity with the angularvelocity
This is because the angular velocity is only changed once and same with the body velocity, you’ll have to constantly change the body velocity, put it on a loop inside of the seat.changed function
Ok, so stuff works fine, the plane can go up and down, right and left but there is one problem, when you want to go up and right at the same time, only one of them works, since im modifying the same bodyangularvelocity. I have tried using 2 angularvelocities in the same part, but for some reason it doesn’t work, is there any solution to this?
local BreakLoop
function StartLoop()
while wait() do
if BreakLoop then break end
if Throttle then
local PitchAngularVelocity
--PitchAngularVelocity = seat.throttle divided or multiplied by a value (to make the plane
--pitch up / down slower / faster)
end
if Steer then
local SteerAngularVelocity
--SteerAngularVelocity = Seat.Steer divided or multiplied by a value (to make the
--plane rotate left/right faster/slower)
end
end
end
game.ReplicatedStorage.PlaneStarted:Connect(function(plr)
if Seat.Occupant = plr.Character then
BreakLoop = false
StartLoop()
end
end
You basically start a loop which updates both angular velocities as they’re both checked.
Then, from that you define Both AngularVelocities and you change them according to a formula like such:
SteerAngularVelocity = seat.Steer / 5 (This will make the SteerAngularVelocity slower than the steer of the seat)
You will also want to add a check to see if the player has left the plane, in which case, break the loop and let the plane’s velocity die out by updating it with a for loop.
EDIT: I just checked the video you sent, That’s probably due to the wrong AngularVelocity math, it seems like it’s pitching on x when it should be pitching on z.