You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
im trying to make a simple helicopter script, i found a tutorial on yt and i tried adding acceleration and deceleration -
What is the issue? Include screenshots / videos if possible!
the deceleration never works, it either doesn’t work at all, makes the helicopter go FASTER or something else that i don’t want -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i’ve tried dividing the movement value, setting it to 0, checking if the player is actively pressing a key ect. nothing seems to work
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
i know movement should not be in a localscript but idk how else i should set it up
the local script for movement
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local cas = game:GetService("ContextActionService")
local seat = nil
local heightIncrease = 0
local rotation = 0
local movement = 0
local moving = false
function height(actionName, actionState)
if actionName == "Up" and actionState == Enum.UserInputState.Begin then
heightIncrease = 15
elseif actionName == "Down" and actionState == Enum.UserInputState.Begin then
heightIncrease = -10
else
heightIncrease = 0
end
end
function rotate(actionName, actionState)
if actionName == "Left" and actionState == Enum.UserInputState.Begin then
rotation = -10
elseif actionName == "Right" and actionState == Enum.UserInputState.Begin then
rotation = 10
else
rotation = 0
end
end
function move(actionName, actionState)
if actionName == "Forward" and actionState == Enum.UserInputState.Begin then
moving = true
for count = 1, 10 do
movement += 8
wait(0.2)
end
moving = false
elseif actionName == "Backward" and actionState == Enum.UserInputState.Begin then
moving = true
for count = 1, 8 do
movement += -5
wait(0.3)
end
moving = false
else
if moving == false then
movement = 0
end
end
end
humanoid.Seated:Connect(function(active, seatPart)
if active and seatPart:IsA("VehicleSeat") and seatPart.Parent.Name == "Helicopter" then
cas:BindAction("Up", height, false, "e")
cas:BindAction("Down", height, false, "q")
cas:BindAction("Left", rotate, false, "a")
cas:BindAction("Right", rotate, false, "d")
cas:BindAction("Forward", move, false, "w")
cas:BindAction("Backward", move, false, "s")
seat = seatPart
elseif not active then
cas:UnbindAction("Up")
cas:UnbindAction("Down")
cas:UnbindAction("Left")
cas:UnbindAction("Right")
cas:UnbindAction("Forward")
cas:UnbindAction("Backward")
seat = nil
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if seat then
local bp = seat.BodyPosition
local bg = seat.BodyGyro
bp.Position = seat.Position + Vector3.new(0, heightIncrease, 0) + (seat.CFrame.LookVector * movement)
bg.CFrame = seat.CFrame * CFrame.Angles(0, rotation, 0)
end
end)
the script that checks whoes in the seat
local bp = Instance.new("BodyPosition")
bp.MaxForce = Vector3.new(0, 0, 0)
bp.Parent = script.Parent.VehicleSeat
local bg = Instance.new("BodyGyro")
bg.MaxTorque = Vector3.new(0, 0, 0)
bg.Parent = script.Parent.VehicleSeat
script.Parent.VehicleSeat.Changed:Connect(function()
local occupant = script.Parent.VehicleSeat.Occupant
if occupant then
local player = game.Players:GetPlayerFromCharacter(occupant.Parent)
if player then
script.Parent.VehicleSeat:SetNetworkOwner(player)
bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bg.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
end
else
bp.MaxForce = Vector3.new(0, 0, 0)
bg.MaxTorque = Vector3.new(0, 0, 0)
script.Parent.VehicleSeat:SetNetworkOwner(nil)
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.