Don’t just copy paste it bruh , the
HealRange
is undefined in my code, define it yourself
Okay so I want you to put a print(#humans) after the get humanoid function is called.
which humanoid function?
this one?
if part.Parent:FindFirstChildWhichIsA("Humanoid") and not table.find(humans, part.Parent:FindFirstChildWhichIsA("Humanoid")) then
table.insert(humans,part.Parent:FindFirstChildWhichIsA("Humanoid"))
end
or this one?
local humans = getHumanoids()
it prints 0 when im not touching the part and 1 when i am, though it doesn’t heal me at all.
Maybe it’s cause the healing is just too slow. Make it add like 50. Also, how much max health does the humanoid have if that doesn’t work.
Try this if that doesn’t work.
local heal : Part = script.Parent
function getHumanoids()
local humans : {Humanoid} = {}
local parts = workspace:GetPartsInPart(heal)
for i, part in pairs(parts) do
if part.Parent:FindFirstChildWhichIsA("Humanoid") and not table.find(humans, part.Parent:FindFirstChildWhichIsA("Humanoid")) then
table.insert(humans,part.Parent:FindFirstChildWhichIsA("Humanoid"))
end
end
return humans
end
while true do
task.wait(1)
local humans = getHumanoids()
print(#humans)
for i, human in pairs(humans) do
human.Health += human.MaxHealth * 0.05
end
end
I noticed why it wouldn’t work, its because i was changing the humanoid’s hp manually on the explorer on the client side and not the server side, i am so dumb. the script works fine.
Great, mark the script as a solution, and make sure to delete/comment out the debug print.
LOL, “hours of testing” just to send the most unoptimized script ever in a topic that’s been resolved
Well, I know for sure yours isn’t working no matter how you set it up..
Make that days ..
--serverscript within a part on the workspace
--s,z,p,m,h = seen,zone,part,model,human
task.wait(4) --loadpause
local humans:{Humanoid}={}
local s,z={},script.Parent
while(true)do s={} task.wait(1)
for _,p in pairs(workspace:GetPartsInPart(z))do
local m=p:FindFirstAncestorWhichIsA("Model")
local h=m and m:FindFirstChildWhichIsA("Humanoid")
if(h and not s[m] and h.Health<h.MaxHealth)then
s[m]=true;h.Health+=1
end
end
end
This version checks parts the same way as AC_Starmarine’s outstanding scripting, but it will do fewer checks with a more direct overall filter. I want your method to work the most here with rather just the touch. Maybe a mix of the two; however, “touchedned” isn’t going to work out.
Even that script is still debatable..
--serverscript within a part on the workspace
--s,z,p,h = seen,zone,part,human
local h:{Humanoid}={}
local s,z=nil,script.Parent
while true do h={} task.wait(1)
for _,p in pairs(workspace:GetPartsInPart(z))do
s=p.Parent:FindFirstChildWhichIsA("Humanoid")or p:FindFirstAncestorWhichIsA("Humanoid")
if(s and not h[s] and s.Health<s.MaxHealth)then h[s]=true s.Health+=1 end
end
end