1_cst
(1 st)
March 28, 2020, 3:49am
#1
Please Help! I’m about to give Up on this. Or How do you Prevent a part from getting Touched in the first place?
Will collision filters work with touched functions on can collide false parts?
local Part = script.Parent
local ignoretable = {"Humanoid"}
Part.Touched:connect(function(hit)
if hit.ignoretable then
else
---- code
end
end)
5 Likes
RoBreadd
(Agidyne)
March 28, 2020, 3:54am
#2
CanCollide parts and CollisionGroups only affect physics.
Your best bet is to check if an instance is inside a table and then ignore it.
hth!
1 Like
1_cst
(1 st)
March 28, 2020, 4:01am
#3
how would I add (Playeradded) and (Charateradded) to the table?
RoBreadd
(Agidyne)
March 28, 2020, 4:04am
#4
What do you mean by adding an event to a table?
1 Like
1_cst
(1 st)
March 28, 2020, 4:05am
#5
sorry for the vague description, I mean when a player joins or dies how do i add their character to the table?
2 Likes
RoBreadd
(Agidyne)
March 28, 2020, 4:09am
#6
If you’re checking whether players will collide or not, you can simply check if the touched part is a parent of any character.
1 Like
1_cst
(1 st)
March 28, 2020, 4:13am
#7
I would like it if the Player did not even collide with the part because i would not have to check for that player
RoBreadd
(Agidyne)
March 28, 2020, 4:15am
#8
Even if the player cannot collide with the part at all, the part will still detect the player there.
You can do:
script.Parent.Touched:connect(function(oP)
if not oP:FindFirstChild("Humanoid") then
-- Do something here
end
end)
2 Likes
1_cst
(1 st)
March 28, 2020, 4:22am
#9
how do i add a video to show you what is happening?
RoBreadd
(Agidyne)
March 28, 2020, 4:23am
#10
You can use Gyazo or record using the in-studio recorder.
1 Like
1_cst
(1 st)
March 28, 2020, 4:26am
#11
i think this might work i did it though my brother YT accout
RoBreadd
(Agidyne)
March 28, 2020, 4:29am
#12
Can you display the whole script?
Correct me if I’m wrong, but you’re trying to stop it from flashing?
1 Like
1_cst
(1 st)
March 28, 2020, 4:32am
#13
Yeah, I tried to shorten the script to be easier to read.
local part = script.Parent
debounce = true
function onTouch(part) -------detects bubble touched
if part.Parent:WaitForChild("Bubble") then
print(part,"Touched")
debounce = false
end
end
function onTouchEnded(part) ------ detects bubble touchEnded
if part.Parent:FindFirstChild("Bubble") then
print(part,"Touched Ended")
debounce = true
end
end
part.Touched:Connect(onTouch)
part.TouchEnded:Connect(onTouchEnded)
while true do ----- this does not matter
if debounce then
part.BrickColor = BrickColor.Random()
end
wait()
end
RoBreadd
(Agidyne)
March 28, 2020, 4:35am
#14
Use :GetTouchingParts()
and check to see if the bubble is touching the brick rather than :TouchEnded()
as that is really unreliable.
1 Like
1_cst
(1 st)
March 28, 2020, 4:37am
#15
Can I use a Print() to see the results with GetTouchingParts()?
RoBreadd
(Agidyne)
March 28, 2020, 4:38am
#16
You’ll need to iterate through it with a pairs loop.
1 Like
1_cst
(1 st)
March 28, 2020, 4:57am
#17
can I do
if GetTouchingParts("Bubble").TouchEnded() then
----- code
end
Try switching your onTouch event function to FindFirstChild instead of WaitForChild.
If you only want the bubble to affect it, maybe something like this
function onTouch(part) -------detects bubble touched
if part.Name=="Bubble" then
debounce = false
end
end
1 Like
RoBreadd
(Agidyne)
March 28, 2020, 5:13am
#19
The best way is to do:
for _, i in pairs(part:GetTouchingParts()) do
if i.Name = "Bubble" then
-- Do something
end
end
Stick that in a loop.
8 Likes
^ that works too, but it kinda just throws away the event structure
2 Likes