Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

humanoid.MoveDirection - returning 0 for X and Z, why?

Asked by 4 years ago

Hello,

I want to apply a force to a part once it get touched by a player tool, so here's my script:

local function onTouch (part)
    print (part.Parent)
    local player = part.Parent.Parent
    print (player.Name)

    if player then
        local humanoid = player:FindFirstChild("Humanoid")      

        if humanoid then
            local direction = humanoid.MoveDirection
            print ('X: ' .. tostring(direction.X))
            print ('Z: ' .. tostring(direction.Z))
            print ('Magnitude: ' .. tostring(direction.Magnitude))
        end
    end
end

There's no error with the script, moveDirection is always returning 0,0 for X and Z doesn't matter from where I touch this part.

I expected X and Z to have values which would help me to define the force direction.

What am I doing wrong? Thanks

0
Could you show a video of how you're moving when you use the tool? gskw 1046 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

MoveDirection doesn't replicate, so you can only view the MoveDirection for your local player.

0
you can put invisible conveyors or teleporters teleporting jjst by small studs if you still dont done it moeck2 7 — 4y
Ad

Answer this question