#problem with script

1 messages · Page 1 of 1 (latest)

barren gyro
#

Hi,
I have a custom movement script for my “earthquake” character, but it keeps moving forward by itself even when I’m not pressing any keys. I need it to stay completely still when there’s no input.

Can you help me fix this?

olive nebula
#

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)