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

Making this only take a specific tool?

Asked by
22To 70
8 years ago

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

Log in to vote
-1
Answered by 8 years ago
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)

0
I don't get it, how does it work? What is that? it doesn't even look like you changed anything... HungryJaffer 1246 — 8y
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 Legoman654 100 — 8y
Ad

Answer this question