Hello, I’ve been trying for a while to make a type of crafting when player drops the item but I can’t even figure out how to detect 2 parts at the same time, this is what I’ve been trying out so far.
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Wood" and hit.Parent.Name == "Stone" then
print("lol")
end
end)
What is the item that the Touched is in?
Is this a crafting spot that the items get dropped on, or are you just dropping the items anywhere and trying to pick up what hits each other.
If it’s the first I’d look into using GetPartsInPart to see what’s in the crafting spot Part.
If it’s the second instead of getting the names of both hit items you could probably modify the Touched events. Check the Model Touched section of the Roblox documentation.
local touching = {}
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Wood" or hit.Parent.Name == "Stone" then
-- Register as touching
touching[hit] = hit.Parent.Name
end
local woodTouching, stoneTouching = false, false
for _, other in touching do
if other == "Wood" then
woodTouching = true
elseif other == "Stone" then
stoneTouching = true
end
if woodTouching and stoneTouching then
print("Both are touching!")
break
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
-- Not touching anymore
touching[hit] = nil
end)
use workspace:GetPartBoundsInBox() what this does is detect objects inside the part.
/
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Wood" or hit.Parent.Name == "Stone" then
local stuffInPart = workspace:GetPartBoundsInBox(-- stuff goes here)
--your other stuff
end
end)
local wood=workspace:WaitForChild("wood")
local stone=workspace:WaitForChild("stone")
local db,set=true,false
wood.TouchEnded:Connect(function() set=false end)
wood.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
set=true
end
end)
stone.TouchEnded:Connect(function() db=true end)
stone.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and set and db then
db=false
print("Touching both")
end
end)