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)
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'