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

Making this only take a specific tool?

ok so this script is in a npc so when they eat it they get the XP but it eats everything listed as a "Tool" and i want it to eat a specific tool not all the tools....EX: it eats swords and guns and all i want it to eat is the Fruit.

local thename = game.Players:findFirstChild(script.Parent.Owner.Value).PlayerGui.GuiProject1
d = script.Parent:Clone()

debounce = false
function t(h)
	if debounce == false then
		debounce = true
		if h.Name == "Handle" then
			if h.Parent.className == "Tool" then
				h.Parent:Remove()
				thename.AnimalHunger.Value = 0
				thename.AnimalXP.Value = thename.AnimalXP.Value + 3
				script.Parent.NOM:Play()
			end
		end
		debounce = false
	end
end

script.Parent.Torso.Touched:connect(t)

1 answer

local thename = game.Players:findFirstChild(script.Parent.Owner.Value).PlayerGui.GuiProject1
d = script.Parent:Clone()

debounce = false
function t(h)
    if debounce == false then
        debounce = true
        if h.Name == "Handle" then
            if h.Parent:IsA('Tool') and h.Parent.Name == "TOOLyouWantRemove" then -- change name here to name of tool you want removed.
                h.Parent:Remove()
                thename.AnimalHunger.Value = 0
                thename.AnimalXP.Value = thename.AnimalXP.Value + 3
                script.Parent.NOM:Play()
            end
        end
        debounce = false
    end
end

script.Parent.Torso.Touched:connect(t)

2 comments

0

I don't get it, how does it work? What is that? it doesn't even look like you changed anything...

0

I forgot to comment on it. I changed line 9 if you check. I made it so it looks for a tool then checks the tools name. You can add other names also. This way it only deletes what you're wanting to remove

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