I have a humanoid inside a model, but it’s Health doesn’t go back after the cooldown. This is supposed to be a very simple problem to solve, but it doesn’t work and I’m very confused about it. I’m not getting any error messages, and when I print the health it states ‘100’ even though it’s 0.
-
What do you want to achieve? Keep it simple and clear!
I’m attempting to make a damagable part with health that drops cash when its at 0 and the cooldown is false -
What is the issue? Include screenshots / videos if possible!
when I run the code, it successfully is damaged and drops cash, but after the cooldown the Health still stays at 0. I’m not sure if this is relevant, but this is inside a server script -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried searching online for others with similar issues, but I don’t see anything. Are server scripts able to change health values?
(the problem is line 12)
Humanoid.HealthChanged:Connect(function()
if COOLDOWN == false and health2.Value <= 0 then
robbed.Value = true
game.ReplicatedStorage.health:FireAllClients(robbed == true)
COOLDOWN = true
sound:Play()
close.Transparency = 1
close.CanCollide = false
open.Transparency = 0
open.CanCollide = true
wait(cooldown_time)
Humanoid.Health = Humanoid.MaxHealth -- the problem
print(script.Parent.Humanoid.Health) --prints 100 even though its 0
close.Transparency = 0
close.CanCollide = true
open.Transparency = 1
open.CanCollide = false
COOLDOWN = false
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.