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

Change Humanoid touch to tool touch?

I have this script that gives me 1 sand if a humanoid touches it. I want to change it so it gives you 1 sand when a tool touches it. Does anybody know how to change it?

script.Parent.Touched:connect(function(part)
	if game.Players:findFirstChild(part.Parent.Name) then
		local plr = game.Players:findFirstChild(part.Parent.Name)
		plr.leaderstats.Ice.Value = plr.leaderstats.Ice.Value + 1
	end
end)
local debounce = true
script.Parent.Touched:connect(function(part)
	if debounce then
		debounce = false
		if game.Players:findFirstChild(part.Parent.Name) then
			local plr = game.Players:findFirstChild(part.Parent.Name)
			plr.leaderstats.Ice.Value = plr.leaderstats.Ice.Value
+1
			script.Parent:destroy()
		end
	end
end)

thanks

1 answer

✓ Accepted answer
script.Parent.Touched:connect(function(part)
	if part.Parent:IsA("Tool") and game.Players:FindFirstChild(part.Parent.Parent.Name) then
		local plr = game.Players:findFirstChild(part.Parent.Parent.Name)
		plr.leaderstats.Ice.Value = plr.leaderstats.Ice.Value + 1
	end
end)

Something like this, I guess

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