Hey, Why Wont The Rig Heal?

So, I got a server script under a rig, and I want the rig to generate health. As a beginner scripter, the solution might be easy but it’s been on my nerves, so any help is well appreciated! Here is the server script:

local healthregn = 10
local wait = 4
local humanoid = rig:WaitForChild(“Humanoid”)
local rig = script.Parent

function regen()

if humanoid then
	rig.Humanoid.Health = rig.Humanoid.Health + healthregn
end

end

while true do
task.wait(wait)
regen()
end

2 Likes

Don’t know why the code did that when I posted but that’s all the code from the colon

2 Likes

cant you just copy the health script from the starter character and place that into the rig?

1 Like

Yep, The Script is already inside the rig (model)

1 Like

Is the humanoid already at full health? It can’t heal if it already is at full health.

2 Likes

oh also, I don’t know if this is how it works, but shouldn’t “local rig” come before “local humanoid”? I think that might be it maybe.

–When it is looking at the if statement it might be trying to understand where the humanoid is–

Yes, it is but when i deal damage using a sword I made and yes, the sword works, it still doesn’t heal

1 Like
local healthregn = 10
local wait = 4
local rig = script.Parent
local humanoid = rig:WaitForChild("Humanoid")

function regen()
	if humanoid then
		print(rig.Humanoid.Health)
		rig.Humanoid.Health += healthregn
	end
end

while true do
	task.wait(wait)
	regen()
end

Lets start with some basic debugging, what does this print?

If the sword is using a LocalScript to deal damage, this script might not work.

2 Likes

Only “100” and it is a server script

1 Like

Yep did that but still not working

1 Like

Yes do check the sword script I had a very similar issue when the rig would die, their ghost would literally haunt me (my weapons would only kill on the client)

can we get any extra footage such as a video?

Pretty sure your sword script is a localscript because when I tested your script it didn’t work if you set the health on client.

2 Likes

But the sword requires mouse input and that is a client function

Then either use a remote event to take damage on the server or make your health regenerate on client.

2 Likes

Yep our try to use a remote event now, thanks

1 Like

Use a remote event to give the server script the mouse

1 Like

That could cause A LOT of lag considering that would mean sending up to 30 signals/second.

2 Likes

I meant mouse position when clicked oops

2 Likes

Or just yeah domething like that

1 Like