I have made a health kit script and I inserted it into a part for the player to heal but the problem is how can I make it respawn every 20 or 30 seconds after the player touches it to heal? please help.
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") -- It finds Humanoids in whoever touched this if (h ~=nil) then -- If there is a Humanoid then h.Health = h.MaxHealth -- Sets the health to maximum (full healing) end end script.Parent.Touched:connect(onTouched)
Note: This is a script not a local script
If you set the parent to nil
its the same as deleting it, but the part is still in the game technically. Then you can pull it back into the workspace, making it appear again.
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if (h ~=nil) then h.Health = h.MaxHealth script.Parent.transparency = 1 local Parent = script.Parent.Parent script.parent.parent = nil wait(math.random(20, 30)) script.Parent.Parent = Parent end end script.Parent.Touched:connect(onTouched)
Something like that