Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

1 comment

0

are you sure the other knives create a creator tag when you use them?

1 answer

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'

1 comment

0

It didn't work. ill update the post to show you the function i have for the creator tag in the knife

This discussion is preserved as it was. New answers, comments, and votes are closed.