Thank you to everyone for your suggestions, but I don’t know how to get the function to work. I made the healing script fire the event, and I’ve spent a bit trying to get it to work. A script in ServerScriptService is what is supposed to heal the player the user clicked. The problem is that I have no idea what to put into the script, since I don’t have much experience with using events. Here’s the script for the tool, it uses a TF2 medigun script which I modified a lot, I think I have to put human.Humanoid.Health = human.Humanoid.Health + 0.6
in the event, but again I’m not sure how to implement it.
Here’s the enitre script for the tool:
local beam = Instance.new("Part")
beam.formFactor = 0
beam.Transparency = 0.1
beam.CanCollide = false
beam.Anchored = true
beam.Locked = true
local Player = game:GetService("Players").LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Human = Character:WaitForChild("Humanoid")
local EquipTrack
local IdleTrack
local HealTrack
beam.Name = "Beam"
beam.Size = Vector3.new(0.6,0.6,0.6)
local m = Instance.new("BlockMesh")
m.Parent = beam
local h = Instance.new("Hint")
local Equip = script:WaitForChild("Equip")
local Idle = script:WaitForChild("Idle")
local Heal = script:WaitForChild("Heal")
--
local uber = game.ReplicatedStorage.uber.Value
local ubercharging = false
local healing = ""
local healingnow = false
local equipped = false
local abletouber = true
local CanUBer = false
function healPlayer(human)
local player = game.Players:GetPlayerFromCharacter(human)
script.Parent.Handle.HealStart:Play()
if player ~= nil and player.Neutral == false and player.TeamColor ~= game.Players:GetPlayerFromCharacter(script.Parent.Parent).TeamColor then
spark()
end
healing = human
healingnow = true
print("TOOL EVENT: " .. script.Parent.Parent.Name:upper() .. " is HEALING " .. human.Name:upper())
if not HealTrack then HealTrack = Human:LoadAnimation(Heal) end
HealTrack:Play()
beam.Parent = script.Parent
beam.BrickColor = BrickColor.new("Bright blue")
beam.Material = Enum.Material.ForceField
while healingnow == true do
if (healing.Torso.Position - script.Parent.H8.Position).magnitude <= 32 then
beam.CFrame = CFrame.new((human.Torso.Position + script.Parent.H8.Position) / 2, human.Torso.Position) * CFrame.fromEulerAnglesXYZ(1.57,0,0)
m.Scale = (m.Scale - Vector3.new(0,m.Scale.y,0)) + Vector3.new(0,0.4,0)
m.Scale = m.Scale + Vector3.new(0,(human.Torso.Position - script.Parent.H8.Position).magnitude - 1,0)
game.ReplicatedStorage.Healthy:FireServer()
script.Parent.H8.ParticleEmitter.Enabled = true
script.Parent.H8.PointLight.Enabled = true
if uber < 1500 and abletouber == true then
uber = uber + 1
end
h.Text = "Ubercharge: ("
for i = 1, math.floor(uber / 100) do
h.Text = h.Text .. "|"
end
for i = 1, 10 - math.floor(uber / 100) do
h.Text = h.Text .. "."
end
h.Text = h.Text .. ")"
else
healingnow = false
healing = ""
ubercharging = false
beam.Parent = nil
spark()
break
end
wait(0.01)
end
end
function spark()
print("TOOL EVENT: " .. script.Parent.Parent.Name:upper() .. " has SPARKED with " .. script.Parent.Name:upper())
script.Parent.H8.PointLight.Enabled = true
script.Parent.Handle.End:Play()
script.Parent.H8.Sparked.Enabled = true
script.Parent.H8.ParticleEmitter.Enabled = false
wait(0.1)
script.Parent.H8.Sparked.Enabled = false
if HealTrack then HealTrack:Stop() end
end
function onButton1Down(mouse)
if mouse.Target == nil then
return
end
if mouse.Target.Parent == nil then
return
end
if mouse.Target.Parent:FindFirstChild("Humanoid") ~= nil then
healPlayer(mouse.Target.Parent)
else
spark()
end
end
function onButton1Up()
healingnow = false
healing = ""
ubercharging = false
m.Scale = (m.Scale - Vector3.new(0,m.Scale.y,0)) + Vector3.new(0,1,0)
beam.Parent = nil
script.Parent.H8.PointLight.Enabled = false
script.Parent.H8.ParticleEmitter.Enabled = false
script.Parent.H8.Sparked.Enabled = false
if HealTrack then HealTrack:Stop() end
end
function onKeyDown(key)
key:lower()
if key == "e" then
if uber == 1500 then
script.Parent.H8.UBER.Enabled = false
abletouber = false
local things = {}
uber = 0
h.Text = "Ubercharge: ("
for i = 1, math.floor(uber / 100) do
h.Text = h.Text .. "|"
end
for i = 1, 10 - math.floor(uber / 100) do
h.Text = h.Text .. "."
end
h.Text = h.Text .. ")"
local c = script.Parent.Parent:GetChildren()
for i = 1, #c do
if c[i].className == "Part" then
c[i].Reflectance = c[i].Reflectance + 0.5
table.insert(things, c[i])
end
end
local ff = Instance.new("ForceField")
script.Parent.Handle.POPPED.Playing = true
table.insert(things, ff)
ff.Parent = script.Parent.Parent
if healing ~= "" then
local b = healing:GetChildren()
for i = 1, #b do
if b[i].className == "Part" then
b[i].Reflectance = b[i].Reflectance + 1
table.insert(things, b[i])
end
end
local sf = Instance.new("ForceField")
sf.Parent = healing
table.insert(things, sf)
end
wait(20)
script.Parent.Handle.POPPED:Stop()
local c = things
for i = 1, #c do
if c[i].className == "Part" then
c[i].Reflectance = c[i].Reflectance - 1
elseif c[i].className == "ForceField" then
c[i]:Remove()
spark()
end
end
abletouber = true
end
end
end
function onEquip(mouse)
script.Parent.Handle.Equip:Play()
if not EquipTrack then EquipTrack = Human:LoadAnimation(Equip) end
EquipTrack:Play()
wait(1.05)
if not IdleTrack then IdleTrack = Human:LoadAnimation(Idle) end
IdleTrack:Play()
h.Parent = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
h.Text = "Ubercharge: ("
for i = 1, math.floor(uber / 100) do
h.Text = h.Text .. "|"
end
for i = 1, 10 - math.floor(uber / 100) do
h.Text = h.Text .. "."
end
h.Text = h.Text .. ")"
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
mouse.Button1Up:connect(onButton1Up)
mouse.KeyDown:connect(onKeyDown)
end
function onUnequip()
h.Parent = nil
healing = ""
healingnow = false
ubercharging = false
beam.Parent = nil
m.Scale = (m.Scale - Vector3.new(0,m.Scale.y,0)) + Vector3.new(0,1,0)
if IdleTrack then IdleTrack:Stop() end
if EquipTrack then EquipTrack:Stop() end
if HealTrack then HealTrack:Stop() end
script.Parent.H8.ParticleEmitter.Enabled = false
script.Parent.H8.UBER.Enabled = false
script.Parent.H8.Sparked.Enabled = false
end
script.Parent.Equipped:connect(onEquip)
script.Parent.Unequipped:connect(onUnequip)
while true do
for i = 1, 5 do
m.Scale = m.Scale + Vector3.new(0.1,0,0.1)
wait(0.1)
end
for i = 1, 5 do
m.Scale = m.Scale - Vector3.new(0.1,0,0.1)
wait(0.1)
end
end