#problem with script
1 messages · Page 1 of 1 (latest)
in the preConn function set root.AssemblyLinearVelocity to Vector3.new(0, v.Y, 0) when wishVelocity() magnitude is zero to stop horizontal movement in postConn ensure horizontal velocity is set to zero when no input keys are pressed preserving vertical velocity
idk i might be wrong
wiat try this:
preConn = RunService.PreSimulation:Connect(function()
if not root.Parent then return end
local wish = wishVelocity()
local v = root.AssemblyLinearVelocity
local vY = v.Y
if wish.Magnitude > 0 then
root.AssemblyLinearVelocity = Vector3.new(wish.X, vY, wish.Z)
else
root.AssemblyLinearVelocity = Vector3.new(0, vY, 0)
end
root.AssemblyAngularVelocity = Vector3.zero
end)
postConn = RunService.Heartbeat:Connect(function()
if not root.Parent then return end
local v = root.AssemblyLinearVelocity
local hasInput = pressed.W or pressed.A or pressed.S or pressed.D
if not hasInput then
root.AssemblyLinearVelocity = Vector3.new(0, v.Y, 0)
end
root.AssemblyAngularVelocity = Vector3.zero
end)