Sup devforum! I know the whole audio update shenanagins have been pretty bad but I kinda need help with something. I’ve been looking around and came across a tank control script and modified it a bit. However there is a glaring issue. Whenever you try and move back, this happens:
Here’s some of the code:
local script:
local function OnBackward (actionName, inputState)
if inputState == Enum.UserInputState.Begin then
movingback = true
moving = false
while movingback do
rotation = player.Character.HumanoidRootPart.Orientation.Y
Xdirection = math.sin(0.0174532925*rotation)*-1*-1
Zdirection = math.cos(0.0174532925*rotation)*-1*-1
wait()
end
elseif inputState == Enum.UserInputState.End then
movingback = false
Xdirection = 0
Zdirection = 0
end
end
ContextActionService:BindAction("Backward", OnBackward, true, Enum.KeyCode.S)
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local leftValue, rightValue, forwardValue, backwardValue = 0, 0, 0, 0
local Xdirection, Zdirection, rotation = 0, 0, 0
local moving = false
local movingback = false
local function OnUpdate()
if player.Character and player.Character:FindFirstChild("Humanoid") then
player.Character.HumanoidRootPart.CFrame *= CFrame.Angles(0, math.rad( (leftValue - rightValue) * 2 ), 0)
player.Character.Humanoid:Move( Vector3.new(Xdirection, 0, Zdirection), false )
end
end