The script just makes it so when I hold D the pirate ship will tilt at a -10 angle on Z axis, then on the Y axis it will keep moving -0.5 while the X axis on position moves 1 until you unhold D
How do I make it so the position wont move weird as in the video.
local userInput = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local debounce = false
local Zrotationvalue = 0
local LetGo = false
local function RightMovementStart(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
if keycode == Enum.KeyCode.D then
LetGo = false
if debounce == false then
while wait(0.001) do
if workspace.Ship.Orientation == Vector3.new(workspace.Ship.Orientation.X, workspace.Ship.Orientation.Y, -10) then
debounce = true
break
end
workspace.Ship.Orientation = Vector3.new(workspace.Ship.Orientation.X, workspace.Ship.Orientation.Y, workspace.Ship.Orientation.Z -0.5)
end
while wait(0.001) do
if LetGo == true then
debounce = true
break
end
workspace.Ship.Position = Vector3.new(workspace.Ship.Position.X + 1, workspace.Ship.Position.Y, workspace.Ship.Position.Z)
workspace.Ship.Orientation = Vector3.new(workspace.Ship.Orientation.X, workspace.Ship.Orientation.Y -0.5, workspace.Ship.Orientation.Z)
end
end
end
end
end
end
local function RightMovementEnd(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
if keycode == Enum.KeyCode.D then
if debounce == true then
LetGo = true
while wait(0.001) do
if workspace.Ship.Orientation == Vector3.new(workspace.Ship.Orientation.X, workspace.Ship.Orientation.Y, 0) then
debounce = false
break
end
workspace.Ship.Orientation = Vector3.new(workspace.Ship.Orientation.X, workspace.Ship.Orientation.Y, workspace.Ship.Orientation.Z +0.5)
end
end
end
end
end
end
userInput.InputBegan:Connect(RightMovementStart)
userInput.InputEnded:Connect(RightMovementEnd)