Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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.

0
Don’t use a local script. You can’t capture the touched event from the client. User#19524 175 — 6y
0
I edited my answer for you. User#21908 42 — 6y
0
if I helped you out please accept my answer. Otherwise comment how I can help you better User#21908 42 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
It does not matter what script you are using. User#21908 42 — 6y
0
However if you are using filtering enable and you are using a local script you will need to use remote events. User#21908 42 — 6y
0
this is not a request website I will not write the entire script for you User#21908 42 — 6y
0
And by the way. Why would you use a local script? User#21908 42 — 6y
View all comments (2 more)
0
Local scripts should only be descendants of the player User#21908 42 — 6y
0
Ok, thanks. Also wondering how to detect if player has stopped touching the part? KingPig999 13 — 6y
Ad

Answer this question