Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my script print the health as 100 while it is 1 and why does it not heal the player?

local healingpad = script.Parent ---Healing Pad
local Green = Color3.fromRGB(96, 255, 99) ---Color Green
local Red = Color3.fromRGB(255,53,53) ---Color Red
local coolDown = 5 ---Cooldown Time
local debounce = false

function heal (hit)
	if debounce then return end
	if hit.Parent:FindFirstChild("Humanoid") then

		print("health")
		print(hit.Parent.Humanoid.Health)
		hit.Parent.Humanoid.Health += 25
		debounce = true
		wait(coolDown)
		debounce = false

	end
end

healingpad.Touched:Connect(heal)

I made this healing script but it doesn't work. Idk why though.

8 comments

0

Maybe you're substracting the health on the client so the server doesn't see it being lower?

0

How do I subtract it on the server?

0

By changing it from a LocalScript to a Script.

0

it is a server script tho

0

it is inside of the healing pad part

0

For some reason setting it to equal works but not adding to it.

0

Nothing wrong with your script. But you're most likely setting the health to 1 on the client while testing it. Switch to server and set the health before you test the script.

0

Thanks can you put that as the answer so I can mark it as answered.

1 answer

✓ Accepted answer

Nothing wrong with your script. But you're most likely setting the health to 1 on the client while testing it. Switch to server and set the health before you test the script.

This discussion is preserved as it was. New answers, comments, and votes are closed.