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

How do I make this script into a script that heals you every 10 seconds?

This is the script I made but I don't think it works that easily.

local lplr = game.Players.LocalPlayer
lplr.Humanoid.Health + 10
wait(20)
repeat

Please help me if you know how do I solve this problem.

2 answers

✓ Accepted answer

Okay you did not use the repeat function(you don't need it in this case) correctly and you did not do you heal function correctly either. That's ok. That's why you asked!

This might work:

local plr = game.Players.LocalPlayer

while true do
	plr.Humanoid.Health = plr.Humanoid.Health + 10
	wait(20) -- Amount of time to wait between healing
end

Here is my new, more efficient method for gear/tool 1: Create tool in StarterPack 2: Create part in Workspace 3: Name part "Handle" with correct capitals and spelling 4: Put part in tool 5: Create script in tool 6: Put code inside script:

local tool = script.Parent
local handle = tool:WaitForChild("Handle") 
local holding = false
local num = 2
local hl = 20
tool.Equipped:Connect(function()
	holding = true
end)

tool.Unequipped:Connect(function()
	holding = false
end)

while wait(num) do
	if holding then
		local plr = tool.Parent
		plr.Humanoid.Health = plr.Humanoid.Health + hl
	end
end

3 comments

0

Doesn't work for some reason, the script will be a effect for a equipable soul I don't exactly know how to do it.

0

Like a tool?

0

Done.

local plr = game.Players.LocalPlayer
local num = 20 --Change this to the amount of time between turns
local hl = 10 --How much health you regen each time

while true do
    plr.Humanoid.Health = plr.Humanoid.Health + hl
    wait(num)
end

Somebody kinda beat me to it but this is the same function just easier for you to make changes to just use while true do to repeat the repeat function will repeat until something changes

2 comments

0

thx

0

ur welcome

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