local partsIn = tool.Part:GetTouchingParts()
print(partsIn)
partsIn is printing {}, even though I have the hitbox inside a part. Any idea why?
(Yes the hitbox is welded to the actual tool)
local partsIn = tool.Part:GetTouchingParts()
print(partsIn)
partsIn is printing {}, even though I have the hitbox inside a part. Any idea why?
(Yes the hitbox is welded to the actual tool)
Also, I don’t know if it matters, but it is in an Activated function.
Does the hitbox have CanCollide and CanTouch on?
You should use GetPartsinPart instead, TouchingParts works really funny and is deprecated.
GetPartsInPart does not exist.
No, but I fixed the initial issue by adding a Touched event to create a touch interest. Now, using table.find() isn’t returning true even though it is clearly in the table.
if table.find(partsIn,"Rice")...```
GetPartsInPart does exist, it is a method of workspace, you don’t need to use a hacky method like adding touch interest using GetPartsInPart
Oh, I see, thankyou for the insight.
Show me your script
zsdzs
tool.Activated:Connect(function()
if debounce then return end
debounce = true
local playAnim = char.Humanoid.Animator:LoadAnimation(animation)
playAnim:Play()
local partsIn = tool.Part:GetTouchingParts()
if table.find(partsIn,"Rice") and farmDebounce == false then
farmDebounce = true
for i, v in pairs(partsIn) do
if v.Name == "Rice" then
game.ReplicatedStorage.CollectRice:FireServer(1, v)
end
end
end
task.wait(.5)
debounce = false
farmDebounce = false
end)
tool.Part.Touched:Connect(function() end)
Doesn’t make it past the table.find() check
Did you try to print the table?? Show me the output
You can’t use table.find on dictionaries
What should I use then? sdfsdffs
it isn’t a dictionary, it is an array (table)
Just do a for loop and check if the value is equal to “Rice”
for index, value in ipairs(partsIn) do
if value == "Rice" then
--stuff
end
end
Can I get the actual object as well (to alter its attribute and stuff)
here is the correction GetTouchingParts returns all the BaseParts that are touching not just the names
Oh, he confused me, because I thought the element was a string
So how can I check if a certain part is in the array