Part doesn't detect collision with other parts, but only players?

So basically, I’m making a pellet that floats down slowly, and when it hits a platform/part, it is supposed to stop going down so a player can get it. The problem is, the part goes straight through all parts/platforms (and doesn’t print “Touched”), but when a player touches it, it stops going down and gives the player walkspeed (and prints “Touched”).

local touch = false
local humtouch = false

while humtouch == false do

if touch == false then
	script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, -0.2, 0)
end
	

script.Parent.Touched:Connect(function(hit)
	print("Touched")
	touch = true
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum then
		if humtouch == false then
			humtouch = true
			hum.WalkSpeed = hum.WalkSpeed + 5
			addbeam(tostring(hit.Parent.Name))
			script.Parent.CanCollide = false
			for i = 0, 1, 0.1 do
				script.Parent.Transparency = i
				wait(0.05)
			end
			script.Parent:Destroy()
		end
	end
end)
    wait()
end

I’ve tried workarounds and region3, but they didnt work. Is there a way to make this work correctly? Thanks.

Is the pellet anchored? Touched events do not detect anchored objects if the parent of the touch detector is anchored as well.

It’s anchored, but when I unanchor it, it would just make the pellet fall instantly.

You could try using Part:GetTouchingParts() in a loop and if the pellet is part of the table of touching parts, fire the code for the pellet.

2 Likes

thanks! this worked very nicely