Damage if a humanoid is moving and if touching a part. humanoid don't get damage if they are standing still

You can write your topic however you want, but you need to answer these questions:

  1. I want to damage the players that is touching and moving in a part

  2. It stills damages you while your not moving

  3. I tried disabling and enabling the script(the damage script is in the part)

local Music = script.Music
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://0"
local controller = game.Workspace.Doll.Humanoid
local Damage = game.Workspace.slowKill.slowDamage
while true do
	Music:Play()
	wait(0.1)
	controller:LoadAnimation(anim):Play()
	wait(0.1)
	Damage.Disabled = false
	wait(7)
	Damage.Disabled = true
end

You can use humanoid.MoveDirection to check whether the player is moving or not.

if humanoid.MoveDirection.Magnitude > 0 then
     -- damage the player
end
2 Likes