#need help with leaderstats
33 messages · Page 1 of 1 (latest)
that script looks for an object named "creator" when the humanoid dies
so where is the script that creates it
because that isnt made by default u have to make it urself
talking about this?
no
the script that adds an object named "creator" to the humanoid
if u dont have one then thats why kills doesn't go up
the creator here is the zombie NPC?
u need to make a script that makes it so whenever someone kills or damages an enemy it adds an ObjectValue with it's Name property being "creator", and with its value being the player who damaged the enemy
then parent the objectvalue to the humanoid
just like what ur scripts trying to find
i should put that script in whatever tool im using to kill the enemy?
?
@modern jungle i referenced the creator in the script its not showing any errors but its not damaging the humanoid too
because if ur only attacking an npc then they dont have a player connected to them
so GetPlayerFromCharacter would return nil
i should write humanoid there then?
or something pertaining to that in nature
yes
since your npc has a humanoid but not a player
so what should i write there exactly
if you wanted it to only apply to non-npcs then you'd check for a player
check if hit.parent has a humanoid
instead of hit.parent being the character of a player
game.ReplicatedStorage.CombatHit.OnServerEvent:Connect(function(plr)
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.Transparency = 1
hitbox.Size = Vector3.new(5,5,5)
hitbox.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)
game.Debris:AddItem(hitbox, 2)
local hits = {}
hitbox.Touched:Connect(function(hit)
if hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name and not table.find(hits, hit.Parent) then
table.insert(hits, hit.Parent)
local EnemyHumanoid = hit.Parent:FindFirstChild("Humanoid")
local sound = script["Punch Kit Beefy Hit 2 (SFX)"]:Clone()
sound.Parent = hit.Parent:FindFirstChild('Humanoid')
sound:Play()
game.Debris:AddItem(sound, 2)
EnemyHumanoid:TakeDamage(30)
if EnemyHumanoid.Health <= 0 then
plr.leaderstats.Kills.Value += 1 -- Replace with whatever adds to the value
end
end
end)
end)
nvm it works
i did what you said