My Fall Damage Script Does Not Detect Sometimes

local Root = script.Parent:WaitForChild("Torso")

local BeforeMagnitude = 0


game:GetService("RunService").Heartbeat:Connect(function()
	
	local Magnitude = Root.Velocity.Magnitude
	local SubtractedMagnitude = (BeforeMagnitude-Magnitude)
	
	if SubtractedMagnitude>=16 and not Root:HasTag("db") and Root.Parent:FindFirstChildWhichIsA("Humanoid").Health>0 then
		Root:AddTag("db")
		script.Parent:FindFirstChildWhichIsA("Humanoid").Health-=Magnitude

		warn("Fall Detected, Damaging by "..Magnitude)
	spawn(function()
			wait(1)
			Root:RemoveTag("db")
		end)
	end
	
	BeforeMagnitude = Magnitude
	
end)

Useally it works pretty well when it does detect, but sometimes it just doesn’t detect. I need some help to find out why so that I can fix my script.

1 Like

Changing it to .Stepped instead of Heartbeat seemed to fix my problems

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.