How would i make a healing staff

i want to make a healing staff that heals everyone inside it’s radius (10 studs) but i don’t know how to the object should be a character because there are enemies in my game with humanoids here are my scripts

server script inside tool
– VARIABLES –
local tool = script.Parent
local properties = require(tool.Properties)

local healingDebounce = false

– FUNCTIONS –
local function createSound(parent, soundProperties)
local sound = Instance.new(“Sound”)
for property,value in pairs(soundProperties) do
sound[property] = value
end
sound.Parent = parent
return sound
end

– HANDLERS –
tool.Activated:Connect(function()
if healingDebounce then return end
if tool.Parent.Humanoid.Health >= tool.Parent.Humanoid.MaxHealth then return end
healingDebounce = true

local healingSound = createSound(tool.Parent.Head, properties.HealingSoundProperties)
healingSound:Play()
healingSound.Ended:Connect(function()
	healingSound:Destroy()
end)
task.wait(properties.AnimationDuration)

if tool.Parent.Name ~= "Backpack" then
	-- player still holding the tool
	tool.Parent.Humanoid.Health += properties.HealingAmount
else
	healingDebounce = false
	return
end

if not properties.OneUse then
	task.wait(properties.HealingCooldown)
	healingDebounce = false
else
	tool:Destroy()
end

end)

local script inside tool -
– SERVICES –
local Players = game:GetService(“Players”)

– VARIABLES –
local tool = script.Parent
local properties = require(tool:WaitForChild(“Properties”))

– animations
local player = Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local humanoid = character:WaitForChild(“Humanoid”)
local animator = humanoid:WaitForChild(“Animator”) :: Animator

local healingDebounce = false

– FUNCTIONS –
local function createTrack(animID)
local animation = Instance.new(“Animation”)
animation.AnimationId = animID
return animator:LoadAnimation(animation)
end
local equipTrack = createTrack(properties.EquipAnimation)

– HANDLERS –
tool.Equipped:Connect(function()
equipTrack:Play()
end)

tool.Unequipped:Connect(function()
equipTrack:Stop()
end)

tool.Destroying:Connect(function()
equipTrack:Stop()
end)

tool.Activated:Connect(function()
if healingDebounce then return end
if humanoid.Health >= humanoid.MaxHealth then return end
healingDebounce = true

local healingTrack = createTrack(properties.HealingAnimation)
healingTrack:Play()
healingTrack:AdjustSpeed(1/properties.AnimationDuration)

if not properties.OneUse then
	healingTrack.Ended:Wait()
	task.wait(properties.HealingCooldown)
	healingDebounce = false
end

end)

module script with all settings-
self = {

HealingAmount = 600, -- how much to heal by

OneUse = false, -- if it's one use or not
HealingCooldown = 10, -- if not one use, set a cooldown time between heals

-- ANIMATIONS
EquipAnimation = "rbxassetid://14096050213",
HealingAnimation = "rbxassetid://14096054899",
AnimationDuration = 3, -- duration for healing animation

HealingSoundProperties = {["SoundId"] = "rbxassetid://444675291", ["RollOffMaxDistance"] = 35, 
	["RollOffMinDistance"] = 15, ["RollOffMode"] = Enum.RollOffMode.InverseTapered, ["Volume"] = 0.2, ["TimePosition"] = 0.8}

}

return self

That is an eyesore, but the general formula for differentiating btwn Player and NPC is to just do Players:GetPlayerFromCharacter(character) and if it returns nil, its an NPC otherwise its a player.

how would i make the script to heal everyone around the player using the staff?

Whenever you want to heal, fire a Remote to the server and in the server get all players inside the radius from the player who fired the remote and then do you healing thing.

ok i will try that out thanks!

i think it works it’s just giving me a few errors im fixing them now

thanks so much it worked really bro!

Anytime :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.