Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Could you show a video of how you're moving when you use the tool?

1 answer

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

1 comment

0

you can put invisible conveyors or teleporters teleporting jjst by small studs if you still dont done it

This discussion is preserved as it was. New answers, comments, and votes are closed.