Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I Used a script that gives you points(souls) but only works for the default knife?

Asked by 2 years ago
Edited 2 years ago

So basically i have a store where you buy a better knife, but when you use the better knife it won't give you points(souls) and only the default knife (the knife you spawn with) works, is there a way i can modify it to make the better knife give points(souls)? Or is there just something wrong with the script?

Script:

local Humanoid = script.Parent.Humanoid
function Dead()
    local tag = Humanoid:FindFirstChild("creator")
    if tag ~= nil then
        local leaderstats = tag.Value:FindFirstChild("leaderstats")
        if leaderstats ~= nil then
            leaderstats.Souls.Value = leaderstats.Souls.Value +1
            wait(0,1)
            script:remove()
        end
    end
end
Humanoid.Died:Connect(Dead)

FYI I put this inside of the enemy NPC and there are no specifics on which knife should work.

function on(t)
    local h = t.Parent:FindFirstChildOfClass("Humanoid")
    if h ~= nil and CanDmg == true then
        CanDmg = false
        local cre = Creator.Value
        h:TakeDamage(parent.Dmg.Value)
        Handle.Swing:Stop()
        Handle.Hit:Play()
        if h.Health>0 then
            if not h:FindFirstChild("creator") then
                local ov = Instance.new("ObjectValue",h)
                ov.Name = "creator"
                ov.Value = game.Players:WaitForChild(cre.Name)
            else
                local ovs = h:GetChildren()
                for i = 1,#ovs do
                    if (ovs[i].Name == "creator") then
                        ovs[i].Value = game.Players:WaitForChild(cre.Name) end
                end

part of the knife's script for the creator tag (yes i already put in a object value that is named Creator)

0
are you sure the other knives create a creator tag when you use them? BabanizPROcuk 49 — 2y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
local Humanoid = script.Parent.Humanoid
function Dead()
    local tag = Humanoid:FindFirstChild("creator")
    if tag ~= nil then
        local leaderstats = tag.Value:FindFirstChild("leaderstats")
        if leaderstats ~= nil then
            leaderstats.Souls.Value = leaderstats.Souls.Value +1
        end
    end
end
Humanoid.Died:Connect(Dead)

This one might work, if you are sure 'it creates a creator tag when you use them'

0
It didn't work. ill update the post to show you the function i have for the creator tag in the knife Icy_limxz 14 — 2y
Ad

Answer this question