Hi, I’m currently working on an obby, in which there are several hundred killbrick.
Many of them are in motion (prismatic, cylindrical and other), so they touch each other and fire the touched event function a lot of time. So many times that these events cause a lot of lag for the game on mobile devices or old PCs.
Is there a way to make a part touchable only by the player character and nothing else? Thank you !
---for i,clone in workspace:GetDescendants() do
if clone:FindFirstChild('KillBrick') then
clone.Touched:Connect(function(hit)
if hit.Parent.Name == plr.Name then
if rs.gameEffects.Invincibilityg.Value == false then
hit.Parent.Humanoid.Health -= 10
else
for i,v in workspace.Tour:GetDescendants() do
if v:FindFirstChild('KillBrick') then
v.CanTouch = false
end
end
end
end
end)
end