How to make uncollidable kill parts that works

local players = game:GetService("Players")

while task.wait() do
	local touching = game.Workspace:GetPartsInPart(script.Parent)
	local playerInPart = false
	for i, v in pairs(touching) do
		if v.Parent:FindFirstChild("Humanoid") ~= nil then
			playerInPart = true 
		if true then
		local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local Ragdoll = require(ReplicatedStorage.Ragdoll)
		v.Parent.Humanoid.Health = 0
		Ragdoll(v)
			end
		end
	end
end

i just end up clipping through, touch doesn’t work with cancollide false anymore so i dunno what i could do

1 Like

You wrote “if true then” true is a general value if you’re using it you have to be specific what is true?

1 Like

playerinpart = true, but it won’t work that way though.
sorry i am abit new to coding

1 Like

In which line does the issue happen? try to use prints.

1 Like

Try modifying to:

local players = game:GetService("Players")

while task.wait() do
	local touching = game.Workspace:GetPartsInPart(script.Parent)
	local playerInPart = false
	for i, v in pairs(touching) do
		if v.Parent:FindFirstChild("Humanoid") ~= nil then
			playerInPart = true
        else
            playerInPart = false
        end
		if playerInPart then
		    local ReplicatedStorage = game:GetService("ReplicatedStorage")
		    local Ragdoll = require(ReplicatedStorage.Ragdoll)
		    v.Parent.Humanoid.Health = 0
		    Ragdoll(v)
		end
	end
end
2 Likes

was able to fix it but, it just leads to same issue.

if playerinpart == true then

no error prompts, by the way

hmm, i tried it but it won’t work and no error prompts either

1 Like

What did you place the script inside? A part, a model or something else?

1 Like

According to BasePart | Roblox Creator Documentation

Even when CanCollide is disabled, parts may still fire the BasePart.Touched event (as well the other parts touching them)

I have also tested myself to make sure this statement is true.
Also, it appears you’re trying to call the ragdoll function on the individual part that touched it instead of the player model, not sure if this was intended but if it was change line 12 to v

local ReplicatedS = game:GetService("ReplicatedStorage")
local Ragdoll = require(ReplicatedS.Ragdoll)

script.Parent.Touched:Connect(function()
	local touching = game.Workspace:GetPartsInPart(script.Parent)
	for i, v in pairs(touching) do
		if not v.Parent then return end
		
		local hum = v.Parent:FindFirstChildOfClass("Humanoid")
		if hum then
			hum.Health = 0
			Ragdoll(v.Parent)
		end
	end
end)
1 Like

just a regular part, really.
it isn’t really any thing else

ohhh, it is supposed to be the player model.
thank you for pointing out the oversight and posting this

Just connect what you would like to do after detecting contact to a .Touched event. It should work even if cancollide is off.

that doesn’t work like that lmao

I used that in my own game, I’m pretty sure it does. Did they change it?

sorry yall, i just found out the part was unanchored.
big mistake on my part, sorry!!

yea it is changed, now you have to do a complicated way to do noncollision part detection

again , i did it and no results so far.
odd.

Read my original post, Touched DOES work with CanCollide set to false. Tell me what this prints

local ReplicatedS = game:GetService("ReplicatedStorage")
local Ragdoll = require(ReplicatedS.Ragdoll)

script.Parent.Touched:Connect(function(Target)
	print("Touched by " .. Target.Name)
	if not Target.Parent then return end

	local hum = Target.Parent:FindFirstChildOfClass("Humanoid")
	if hum then
		print("It has a humanoid!")
		hum.Health = 0
		Ragdoll(Target.Parent)
	end
end)
2 Likes

I just checked in my own game, it still works. The game was last updated July of last year.

If the part was invisible and unanchored with cancollide off, then it probably fell into the void and you didn’t notice. Try using the touched event again.

2 Likes

my apologies, it’s 1am and i may have tried the wrong one
it does work, i appericate you sticking around to help me, yall!!!

1 Like