I am trying to make a ship that is driven by BodyGyro, BodyPosition and BodyVelocity all kept inside of a VehicleSeat. Everything works except it does not travel up or down, I made two separate scripts to fix the problem, but neither of them seem to work. The first script just turns the other on and off when a player gets in or out of the seat and the second script changes the y axis of the BodyPosition when the player in the seat presses q or e. Here are the scripts:
Script 1:
local Move = script:FindFirstChild("move")
script.Parent.ChildAdded:connect(function(child)
if child:IsA"Weld" and child.Name == "SeatWeld" then
local p1 = child.Part1
if p1.Parent:IsA"Model" then
local char = p1.Parent
if game.Players:FindFirstChild(char.Name) then
script.Parent.CurrentSeatedPlayer.Value = game.Players[char.Name]
Move.Disabled = false
end
end
end
end)
script.Parent.ChildRemoved:connect(function(child)
if child:IsA"Weld" and child.Name == "SeatWeld" then
Move.Disabled = true
script.Parent.CurrentSeatedPlayer.Value = nil
end
end)
Script 2:
pos = script.Parent.Parent:FindFirstChild("BodyPosition")
function onKeyDown(key)
key:lower()
if key == "q" then
pos.CFrame + Vector3.new(0,(Height/5),0)
end
function onKeyDown(key)
key:lower()
if key == "q" then
pos.CFrame - Vector3.new(0,(Height/5),0)
end

1 comment
Also, you need to fix the functions (end)