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.
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
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?