Hello, I’m making a system where killing someone with the finisher system will grant you health.
Keep in mind I have added the creator tag inside the weapon’s server script.
I’m facing a problem where you cannot get more health when performing a finisher near to a downed player, the finisher system works totally fine.
I tried printing/debugging it and the output did print when the finisher system has begun and has ended.
it did printed when the KillForHP was not disabled and disabled but it does not give the player health if they have less than their max health
The LocalScript is parented inside the Tool,
the KillForHP (server script) is also parented inside the Tool.
Here’s the LocalScript:
-- Client
elseif actionName == "Finisher" and Equipped == true and inpState == Enum.UserInputState.Begin and Tool.KillForHP.Disabled then
for _, v in pairs(workspace:GetDescendants()) do
local HumanoidRootPart = v:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart and HumanoidRootPart:IsA("BasePart") and not Glory then
if (HumanoidRootPart.Position - Character.HumanoidRootPart.Position).Magnitude < 5 and HumanoidRootPart.Parent.Values.Downed.Value == true and not Finisher and Slashing == false and Glory == false then
Finisher = true
Humanoid.WalkSpeed = 5
Tool.KillForHP.Disabled = false -- This is the server script that gives player health
Humanoid.JumpPower = 0
RemotesFolder.Finisher:FireServer(Character, HumanoidRootPart)
ToolAnims.Finish:Play()
wait(1.4)
Tool.KillForHP.Disabled = true
Finisher = false
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end
end
end
return Enum.ContextActionResult.Pass
end
And here’s the KillForHP server script:
-- Server
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local hum = char.Humanoid
hum.Died:Connect(function()
local creator = hum:FindFirstChild("creator")
if creator ~= nil then
local kill = creator.Value
if kill ~= nil then
kill.Character.Humanoid.Health = kill.Character.Humanoid.Health + 30
end
end
end)
end)
end)
If you’re still curious and want more explanation/proof, feel free to ask me.
I’m curious as you’ve said in your post you’re looking for the creator tag within the weapon’s server script, but in your KillForHp script you’re using FindFirstChild which finds names, not tags.
Also, I don’t know if you know how to use it, but learning the debugger with breakpoints, watches and such is a really great way to be able to debug and find out the exact issue. It cut my debugging time in half, if not more. Here’s the link to the creator docs to get started with it Debugging | Roblox Creator Documentation!
The “weapon’s server script” handles all OnServerEvent remote events, damage player upon contact, etc. I called functions that tags and untags the creator value on the player’s humanoid (not the player’s humanoid that is holding the weapon) in the hitbox handling code block.
I’m not sure I fully understand, is the FindFirstChild in the KillForHp looking for an object with a tag of “creator” or is it looking for an object with the name “creator”?
Unrelated but side note, the client script will not be able to disable the serverscript like you have posted. And as for the function not starting at all, it doesn’t even trigger PlayerAdded?
No it does not trigger the PlayerAdded event and I could place it in ServerScriptService but I cannot disable it. I’ll try to disable the KillForHP script from the weapon server script that fired the Finisher remote event.
If I do that, the player can get health without killing the player via finisher. I use RaycastHitBoxV4 to raycast the damage and whether the finisher was a success and killed the player.
There’s no reason but the script works fine, it works totally fine but it’s the KillForHP that doesn’t work properly, when i keep the KillForHP enabled, it gives the player hp if they killed a player as well as killing them via finisher but what i want is the player getting more health (not MaxHealth) when they kill them with the finisher instead of basically killing them.
The KillForHP can only works when the UntagHumanoid and TagHumanoid functions are called, similar to the roblox sword in the toolbox.
Here’s the code block I called the UntagHumanoid and TagHumanoid functions:
-- Server
elseif humanoid and humanoid ~= script.Parent.Parent.Humanoid and humanoid.Parent.Values.Parrying.Value == false and humanoid.Parent.Values.Downed.Value == true then
humanoid:TakeDamage(100)
UntagHumanoid(humanoid)
TagHumanoid(humanoid, Player)
Tool.Handle.Impact:Play()
end
I copied the UntagHumanoid and TagHumanoid functions from roblox’s sword in toolbox.
I called the UntagHumanoid and TagHumanoid inside the finisher remote event like this:
-- Server
RemotesFolder.Finisher.OnServerEvent:Connect(function(Player, Char, HumanoidRootPart)
if (HumanoidRootPart.Position - Character.HumanoidRootPart.Position).Magnitude < 15 and ValuesFolder:WaitForChild("Equipped").Value == true and ValuesFolder:WaitForChild("DoFinisher").Value == false and HumanoidRootPart.Parent.Values.Downed.Value == true and HumanoidRootPart.Parent.Humanoid.Health > 0 and ValuesFolder:WaitForChild("Slashing").Value == false then
ValuesFolder:WaitForChild("DoFinisher").Value = true
wait(0.5)
Hitbox:HitStart()
wait(1)
Hitbox:HitStop()
UntagHumanoid(Humanoid)
TagHumanoid(Humanoid, Player)
ValuesFolder:WaitForChild("DoFinisher").Value = false
end
end)
and it printed an error in the output
It got an error when checking the humanoid’s child if its name is “creator” and is an ObjectValue inside the UntagHumanoid function. Better known as for i, v in pairs(humanoid:GetChildren()) do