#need help with leaderstats

33 messages · Page 1 of 1 (latest)

modern jungle
#

well where do you create the "creator" tag

#

bc thats what ur script is checking for

uncut trench
#

the creator here is implying the zombie?

modern jungle
# uncut trench

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

uncut trench
modern jungle
#

the script that adds an object named "creator" to the humanoid

#

if u dont have one then thats why kills doesn't go up

uncut trench
modern jungle
#

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

uncut trench
uncut trench
#

@modern jungle i referenced the creator in the script its not showing any errors but its not damaging the humanoid too

modern jungle
#

because if ur only attacking an npc then they dont have a player connected to them

#

so GetPlayerFromCharacter would return nil

uncut trench
#

or something pertaining to that in nature

modern jungle
#

since your npc has a humanoid but not a player

uncut trench
#

so what should i write there exactly

modern jungle
#

if you wanted it to only apply to non-npcs then you'd check for a player

modern jungle
#

instead of hit.parent being the character of a player

uncut trench
#
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