I’ve changed the player character into a part. I’m changing the movement system as well.
I’ve made it so that while the W key is being pressed, the part keeps moving in the x-axis. The part is moving via a tween.
Everything is working fine except the fact that whenever the W key is pressed, a slight jittery effect is visible. Is it possible to remove this effect?
I’m sorry if the code is too naive; I’m just starting out, so the code might seem a bit disorganized and inefficient. If there’s a better way to achieve this, do let me know. Any help is appreciated.
-- Disabling Player Movement
local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()
local Tween = game:GetService("TweenService")
Controls:Disable()
-------------
local CAS = game:GetService("ContextActionService")
local character = script.Parent:WaitForChild("HumanoidRootPart")
local press = false
local function moveX(name,state,action)
if state == Enum.UserInputState.Begin then
press = true
while press == true do
Tween:Create(character, TweenInfo.new(.05,Enum.EasingStyle.Sine, Enum.EasingDirection.InOut,0,false), {CFrame = character.CFrame * CFrame.new(.5,0,0) }):Play()
wait()
end
elseif state == Enum.UserInputState.End then
press = false
end
end
CAS:BindAction("moveForward", moveX , false, Enum.KeyCode.W)
character.Position = Vector3.new(0,2,0)