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

Make a script when you touch a npc with a tool, the tool gets destroyed and you get money? [closed]

Asked by 3 years ago
Edited 3 years ago

I tried to make a script where you touch a npc with a tool and the tool in your hand gets destroyed and then you get money, but nothing seems to work.

0
It would help more if you included your code. DesertusX 435 — 3y

Closed as Not Constructive by JesseSong, TaxesArentAwesome, and Nguyenlegiahung

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

ok, first create hitbox for your NPC make hitbox CanCollide = false then create a script in hitbox then try to use this script

local Hitbox = script.Parent
Hitbox.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("HumanoidRootPart")
    then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr.Backpack:FindFirstChild("ItemNameHere") -- ItemNameHere = Replace it with your item name
        then
            plr.Backpack.ItemNameHere.Parent = nil -- Destroy progress, make parent  of it to nil (ItemNameHere = Replace it with your item name)
            plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 20 -- 20 = Money player got you can change it
        elseif plr.Character:FindFirstChild("ItemNameHere") then -- Replace ItemNameHere with your item name
            plr.Character.ItemNameHere.Parent = nil -- Make parent to nil (ItemNameHere = Replace it with your item name)
            plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 20 -- Replace 20 with value up to you

            end
    end
end)

-- Ended, sorry if this script does not work... -- 

Ended, sorry if this script does not work... EDIT: I didn't test this script, sorry if this script does not work

Ad