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:

01local function onTouch (part)
02    print (part.Parent)
03    local player = part.Parent.Parent
04    print (player.Name)
05 
06    if player then
07        local humanoid = player:FindFirstChild("Humanoid")     
08 
09        if humanoid then
10            local direction = humanoid.MoveDirection
11            print ('X: ' .. tostring(direction.X))
12            print ('Z: ' .. tostring(direction.Z))
13            print ('Magnitude: ' .. tostring(direction.Magnitude))
14        end
15    end
16end

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