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

Help me with my healer script?

Trying to make it where you touch it and your health is regenerated back to 100. And then it is transparent and non-cancollided for 10 seconds. While disabling the script for 10 seconds. I have been optimizing this script for awhile and I don't know what else to do.

local Part = script.Parent

function onTouch()
	local Humanoid = Part.Parent:FindFirstChild("Humanoid")
		if (Player ~= nil) then
			Humanoid.Health = 100
							end
end
Part.Touched:connect(onTouch)
function onTouch()
	if (Player ~= nil) then
		Part.Transparency = 0
		Part.CanCollide = false
		wait(10)
		Part.Transparency = 1
		Part.CanCollide = true
	end
end
Part.Touched:connect(onTouch)

function onTouch()
	if (Player ~= nil) then
		script.Disabled = true
		wait(10)
		script.Disabled = false
	end
end

1 answer

✓ Accepted answer

I edited your script a bit.

debounce=true --Fist debounce
script.Parent.Touched:conenct(function(hi) --Parent touched
if debounce then --If debounce is true
debounce=false --Debounce is false
find=hi.Parent:FindFirstChild("Humanoid") --Find the Humanoid that is within the player that touched the Parent
if find then --If find exists
find.Health=find.MaxHealth --Restores health
script.Parent.Transparency=1 --Invisible
script.Parent.CanCollide=false --Can walk through

wait(20) --Waits 20 seconds

script.Parent.Transparency=0 --Visible again
script.Parent.CanCollide=true --Can not walk though
debounce=true --Debounce is now true again
end end end) --All the ends for the function, and if loops

I hope this helped!

1 comment

0

Didnt work...

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