When I try to tween the health it errors

This is the code:

function module.Dmg(plr,dmg)
	local char = plr.Character
	local hum = char.Humanoid
	local dmgTween = tweenService:Create(hum.Health,TweenInfo.new(1,1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false){Health=10})
	dmgTween:Play()	
	if plr.Status.plrEffects:GetAttribute("Bleeding") == false then
		dmgTween:Stop()	
	end
end

BTW: I renamed the function to damage at some point with the same error
This is the error:

1 Like

change this to just hum, not hum.Health. The script is trying to find the Health value in Health itself.

I got the same error even though I changed it.

local dmgTween = tweenService:Create(hum,TweenInfo.new(1,1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false){Health=10})

Your second parameter here is wrong, I’m pretty sure…

As Kilo said, multiple things are wrong with your code. Here is a fixed version, with the parameters in the correct order and properly seperated with commas.

function module.Dmg(plr,dmg)
	local char = plr.Character
	local hum = char.Humanoid
	local dmgTween = tweenService:Create(hum,TweenInfo.new(1,Enum.EasingStyle.Linear), {Health=10})
	dmgTween:Play()	
	if plr.Status.plrEffects:GetAttribute("Bleeding") == false then
		dmgTween:Stop()	
	end
end

Try this.

local dmgTween = tweenService:Create(hum, TweenInfo.new(1, Enum.EasingStyle.Linear){Health = 10})

I got the same error again, sorry

Did you try Pay’s script as well?

Yes, I did, with the same error. I am so confused

local tweenService = game:GetService("TweenService")

function module.Dmg(plr, dmg)
	local char = plr.Character
	local hum = char:FindFirstChildOfClass("Humanoid")

	if hum then
		local dmgTween = tweenService:Create(hum, TweenInfo.new(1, 1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false), { Health = hum.Health - dmg })
		dmgTween:Play()

		if plr.Status.plrEffects:GetAttribute("Bleeding") == false then
			dmgTween:Stop()
		end
	else
		warn("Humanoid not found in player's character.")
	end
end

Your arguments or parameters are most likely messed up somewhere. Send the error here so people can debug it easier.


This is the error I am dealing with.I tried the one reset sent and got the same error. I don’t think it’s my humanoid.

1 Like

You are trying to call a function named “Damage” whilst the function that you want to call is named “Dmg”. Also it looks like you forgot to send the 2nd argument (damage amount).

OMG, My eyesight! I’ll try changing it now

I got a different error this time, so something is working

function module.Dmg(plr, dmg)
	local char = plr.Character
	local hum = char:FindFirstChildOfClass("Humanoid")

	if hum then
		local dmgTween = tweenService:Create(hum, TweenInfo.new(1, 1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false), { Health = hum.Health - dmg })
		dmgTween:Play()

		if plr.Status.plrEffects:GetAttribute("Bleeding") == false then
			dmgTween:Stop()
		end
	else
		warn("Humanoid not found in player's character.")
	end
end

local lib = require(game.ReplicatedStorage.Assets.Modules.ServerLibrary) local dmg = 19 lib.Dmg(game.Players.MornekoKai)

You accidentally put the image inside the code block.

Change the “dmgTween” variable to this:

local dmgTween = tweenService:Create(hum, TweenInfo.new(1, Enum.EasingStyle.Linear){Health = 10})

This is happening now

My bad, I forgot a comma.

local dmgTween = tweenService:Create(hum, TweenInfo.new(1, Enum.EasingStyle.Linear), {Health = hum.Health - dmg})

This seems to have worked, thanks for the help!

function module.Dmg(plr, dmg)
	local char = plr.Character
	local hum = char:FindFirstChildOfClass("Humanoid")

	if hum then
		local dmgTween = tweenService:Create(hum, TweenInfo.new(1, Enum.EasingStyle.Linear), {Health = 10})
		dmgTween:Play()
	--	if plr.Status.plrEffects:GetAttribute("Bleeding") == false then
	--		dmgTween:Stop()
	--	end
	--else
	--	warn("Humanoid not found in player's character.")
	end
end
1 Like