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

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

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.

1 comment

0

It would help more if you included your code.

1 answer

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

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