I’m trying to make a punching bag that when it dies, it gives the player who killed it some strength. Through my combat system, I tag the model with an objectvalue named “Deb” and the value of it is set to the player who hit the punching bag. However, when I test it and I kill the humanoid in the punching bag, I am not getting any response from humanoid.died as the print(“humanoid died”) isn’t even showing up in the output. Does anyone know how I can fix this? If you need more information to help me, I will gladly provide it.
script.Parent.Humanoid.Died:Connect(function()
print("Humanoid died")
if script.Parent:FindFirstChild("Deb") ~= nil then
local Killer = script.Parent.Deb.Value
Killer.leaderstats.Strength.Value += 100
print("Strength given.")
end
end)
script.Parent.Humanoid.Died:Connect(function()
print("Humanoid died")
if script.Parent:FindFirstChild("Deb") ~= nil then
local Killer = script.Parent.Deb.Value
Killer.leaderstats.Strength.Value += 100
print("Strength given.")
end
end)
I won’t use an objectValue, but a stringValue, then the value is set to the player’s name?
Second: Killer.leaderstats.Strength.Value += 100 is wrong. Replace this line with Killer.leaderstats.Strength.Value = Killer.leaderstats.Sternght.Value + 100
Here’s the local script that fires the server event.
Player = game.Players.LocalPlayer
repeat wait() until Player.Character
Character = Player.Character
Tool = script.Parent
Enabled = true
Tool.Activated:Connect(function()
if Enabled == true then
script.Function:FireServer("Combat", Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2).p)
end
end)
Here is the main script for animations and damage.
Enabled = true
Combo = 1
script.Parent.OnServerEvent:Connect(function(Player, Action, V1)
local c = Player.Character
local damage = Player.leaderstats.Strength.Value
if Enabled == false then
return
end
if Action == "Combat" then
Enabled = false
if Combo == 1 then
Combo = 2
local Track = Instance.new("Animation")
Track.AnimationId = "rbxassetid://5577440669"
local Anim = c.Humanoid:LoadAnimation(Track)
Anim:Play()
elseif Combo == 2 then
Combo = 1
local Track = Instance.new("Animation")
Track.AnimationId = "rbxassetid://5577441980"
local Anim = c.Humanoid:LoadAnimation(Track)
Anim:Play()
end
wait(0.2)
local Region = Region3.new(V1 - Vector3.new(2,2,2), V1 + Vector3.new(2,2,2))
local RTable = workspace:FindPartsInRegion3(Region, nil, 20)
for i, v in pairs(RTable) do
if v.Parent:FindFirstChild("Humanoid") and v.Parent:FindFirstChild("Deb") == nil and v.Parent ~= c then
local Deb = Instance.new("ObjectValue", v.Parent)
Deb.Name = "Deb"
Deb.Value = Player
game.Debris:AddItem(Deb, 0.5)
v.Parent.Humanoid:TakeDamage(damage)
local S = Instance.new("Sound", v)
S.SoundId = "rbxassetid://3932506625"
S.PlaybackSpeed = math.random(80,120)/100
S:Play()
end
end
wait(0.31)
Enabled = true
end
end)
These won’t fix my issues because my Humanoid.Died function isn’t even working. If I get the Humanoid.Died function to work and the script still does not work, I will try these though!
I’m not getting negative numbers for the humanoid health anymore, but Humanoid.Died is still not working because I’m not getting the print"humanoid died" in the output.