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

Can touched event detect players with cancollide off?

I need to check if a player is in a zone, but when i come into the brick, nothing is appearing in the console.

b = true
script.Parent.Touched:Connect(function(hit)
	print("you touched me :(")
	if game.Workspace.Temp.Errored.Value and b then
	p = 1
	b = false
	local a = hit.Parent:FindFirstChild("Humanoid")
    if a ~= nil and p == 1 then
    wait(5)
	game.Workspace.Pipes.Pipe1.Transparency = 1
	game.Workspace.Pipes.Pipe2.Transparency = 1
	game.Workspace.Pipes.Pipe3.Transparency = 1
	game.Workspace.Pipe1.Transparency = 0
	game.Workspace.Temp.Errored.Value = 0
	game.Workspace.Temp.Errored2.Value = 0
	wait(10)
	b = true
end
end
end)

script.Parent.TouchEnded:Connect(function()
	print("you stopped touching me :)")
	p = 0
end)

It does detect touches from other parts, though. In here it says that invisible detection is a thing. EDIT: After some time this problem disappeared, weird

5 comments

0

Why are you checking if Temp.Errored.Value equals true?

0

Boolvalue.

0

But on line 14, OP assigns Errored.Value to zero.

0

Other stuff in the game makes Errored.Value true, "you touched me" is not appearing when I get in the brick

0

Okay, after some time it started working. Not sure what was wrong though.

2 answers

Yes, Even with CanCollide off, it can still detect players.

2 comments

0

This should be a comment, make this worth being an answer.

0

But how? Why is this not working then?

Simple answer: Yes yes it can

Long answer: The part is still being touched, even with transparency 0 and cancollide set to false, therefore the ontouched event will still fire. You can try this in a brick that has 0 transparency and cancollide set to false to be sure:

script.Parent.Touched:Connect(function(hit)
print(hit.Parent.Name)
end)
--if it prints the player name then it works, which it should

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