Tween still plays even when i have an if statement to prevent it from running on died

I have a script that plays a bunch of tweens when the player is “ragdolled” however when the player dies they get ragdolled meaning the tweens also play, but i don’t want them to play on .Died, i tried setting a humanoid health check and it still runs regardless.

script.Parent.Values.Downed.Changed:Connect(function(__INST)
	if __INST == true and Humanoid.Health >= 0 then -- This shouldn't run because the player dies at exactly 0 health, yet it does.
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
		if shift.Enabled == false then
			shift.Enabled = true
		end
		__DOWNEDCOLOR.Enabled = true
		task.wait(0.1)
		__HEART:Play()
		game:GetService("TweenService"):Create(__DOWNEDCOLOR, TweenInfo.new(1), {TintColor = Color3.fromRGB(255, 93, 96)}):Play()
		game:GetService("TweenService"):Create(Gui, TweenInfo.new(1), {ImageTransparency = 0.5}):Play()
	else
		__DOWNEDCOLOR.Enabled = false
		shift.Enabled = true
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
		game:GetService("StarterGui"):SetCore("ResetButtonCallback", true)
		task.wait(0.1)
		__HEART:Stop()
		game:GetService("TweenService"):Create(__DOWNEDCOLOR, TweenInfo.new(1), {TintColor = Color3.fromRGB(255, 255, 255)}):Play()
		game:GetService("TweenService"):Create(Gui, TweenInfo.new(1), {ImageTransparency = 1}):Play()
	end
end)

might be cause the tween is on loop

You should probably use the humanoid.Died event instead of checking if the health is above 0.

1 Like