So, I'm using the default Roblox Medkit (the one seen in the template) and I get the following error: Players.relatlves.Backpack.Medkit.MedkitScript:30: attempt to index local 'character' (a nil value) I've tried putting the ROBLOX_HumanoidList in ServerStorage incase the code that puts the HumanoidList in ServerStorage doesn't work anymore. Code:
local tool = script.Parent if not game.ServerStorage:FindFirstChild("ROBLOX_HumanoidList") then tool.ROBLOX_HumanoidList:Clone().Parent = game.ServerStorage end local HumanoidList = require(game.ServerStorage.ROBLOX_HumanoidList) local lastHealed = os.time() local configTable = tool.Configurations local configs = {} local function loadConfig(configName, defaultValue) if configTable:FindFirstChild(configName) then configs[configName] = configTable:FindFirstChild(configName).Value else configs[configName] = defaultValue end end loadConfig("HealAmount", 20) loadConfig("HealDistance", 10) loadConfig("HealCooldown", 2) tool.Activated:Connect(function() local now = os.time() if now - lastHealed >= configs["HealCooldown"] then lastHealed = now -- Find all nearby humanoids and heal them if in range local humanoids = HumanoidList:GetCurrent() for _, humanoid in pairs(humanoids) do local character = humanoid.Parent if character:FindFirstChild("HumanoidRootPart") then local distance = (tool.Handle.Position - character:FindFirstChild("HumanoidRootPart").Position).magnitude if distance < configs["HealDistance"] then humanoid.Health = humanoid.Health + configs["HealAmount"] local healSmokeThread = coroutine.create(function() local smoke = Instance.new("Smoke", character:FindFirstChild("HumanoidRootPart")) smoke.Color = Color3.new(0,1,0) smoke.Opacity = 0.3 wait(2) smoke:Destroy() end) coroutine.resume(healSmokeThread) end end end end end)
HumanoidList Code:
local humanoidList = {} local storage = {} function humanoidList:GetCurrent() return storage end local function findHumanoids(object, list) if object then if object:IsA("Humanoid") then table.insert(list, object) end for _, child in pairs(object:GetChildren()) do local childList = findHumanoids(child, list) end end end local updateThread = coroutine.create(function() while true do storage = {} findHumanoids(game.Workspace, storage) wait(3) end end) coroutine.resume(updateThread) return humanoidList
Edit: Yes, I did try editing the code, it just made it worse.