Thats the point. ‘WaterWL’ is just a table with all the bricks that should be given a touched event. I left out the function within the actual code because it isn’t necessary.
I think it is going to start by listening for the touched event on the first brick in your table
so basically until it is touched all other bricks are ignored, that might be your problem
A great way to listen for all of your parts to be touched is by tagging them all using CollectionService
and then calling your function when one of the tagged parts is hit, also referencing CollectionService.
I may be wrong, but I believe that CollectionService can be referenced, edited by server and client, which would fit you need for client/server flexibility
It might seem silly, but did you verify that the local script is actually running? It would also be helpful to see the output of #WaterML like @Legoracer mentioned to verify the local script is actually finding all the parts. I think only at that point could you confirm it is actually the Touched event that isn’t working.
Due to how parts replicate to the client, it is best to use WaitForChild for indexing anything.
I can’t think of any reason behind this. Try adding print() in the for loop AND in the start and end of the function so that we can know if:
a) the script actually goes through any part at all
b) the Touched event actually gets called
c) the function in the Touched event ends correctly
Yup! You are correct. Not only that, when using CollectionService you can add a tag on the client and remove it from the server and vice versa. Using CollectionService is definitely a good habit to get into in my opinion, especially for this use case.
My approach to this situation would be:
local WaterWL = {
workspace:WaitForChild("TestPart", 1),
workspace:WaitForChild("TestPart2", 1)
}
local CollectionService = game:GetService("CollectionService")
for _,v in pairs (WaterWL) do
CollectionService:AddTag(v, "TouchingParts")
end
for _,v in pairs (CollectionService:GetTagged("TouchingParts")) do
v.Touched:Connect(function()
print("Touching!")
end)
end