You can use any version, the Roblox one or the copied one. Just do the same steps though.
2 Likes
Thank you so much for your help, everything is working but any bullet that strikes the player after death adds another kill even if it was just one.
I added a check.
Switch out the function for this:
function WeaponsSystem.doDamage(target, amount, damageType, dealer, hitInfo, damageData)
if not target or ancestorHasTag(target, "WeaponsSystemIgnore") then
return
end
if IsServer then
local targetPlayer = Players:GetPlayerFromCharacter(target.Parent)
if targetPlayer and target:IsA("Humanoid") and dealer:IsA("Player") and dealer.Character then
local dealerHumanoid = dealer.Character:FindFirstChildOfClass("Humanoid")
if dealerHumanoid and target ~= dealerHumanoid then
-- Trigger the damage indicator
WeaponData:FireClient(targetPlayer, "HitByOtherPlayer", dealer.Character.HumanoidRootPart.CFrame.Position)
end
end
-- NOTE: damageData is a more or less free-form parameter that can be used for passing information from the code that is dealing damage about the cause.
-- .The most obvious usage is extracting icons from the various weapon types (in which case a weapon instance would likely be passed in)
-- ..The default weapons pass in that data
local handler = _damageCallback or _defaultDamageCallback
handler(WeaponsSystem, target, amount, damageType, dealer, hitInfo, damageData)
-- Check if target is dead
if targetPlayer and not target:GetAttribute("wasKilled") and target.Health <= 0 then
target:SetAttribute("wasKilled", true)
-- Give dealer a kill
dealer.leaderstats.Kills.Value += 1
-- Give target a death
targetPlayer.leaderstats.Death.Value += 1
end
end
end
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.