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

How do I detect if a player is touching a brick that has CanCollide set to false?

I'm wondering how I can get a non-CanCollide part to detect if a player is touching it, but I don't really have any idea how to do this. What I do know is that this is going to use a local script.

3 comments

0

Don’t use a local script. You can’t capture the touched event from the client.

0

I edited my answer for you.

0

if I helped you out please accept my answer. Otherwise comment how I can help you better

1 answer

A Touched event still fires even if CanCollide is set to false like so:

script.Parent.CanCollide =  false

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then -- checks if a player is touching it
		print("Hello World!")
	end
end)

-- output --> Hello World!

Hope this helps and have a great day scripting!

Edit 1:

script.Parent.TouchEnded:Connect(function() -- TouchEnded is the way to go

end)

6 comments

0

It does not matter what script you are using.

0

However if you are using filtering enable and you are using a local script you will need to use remote events.

0

this is not a request website I will not write the entire script for you

0

And by the way. Why would you use a local script?

0

Local scripts should only be descendants of the player

0

Ok, thanks. Also wondering how to detect if player has stopped touching the part?

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