I am trying to make a script where if a ball hits a part a particle goes off. I have to parts and the script is located in ServerScriptServices
The problem is both parts’ particles go off
How do I fix this
-- SERVER SCRIPT LOCATED IN SERVERSCRIPTSERVICES
-- Get references to the ball and particle effects
local ball = workspace.Ball
local partO = workspace.PartO
local partB = workspace.PartB
local ballSpawn = workspace.BallSpawn
local particle1 = partO.Attachment.ParticleEmitter
local particle2 = partB.Attachment.ParticleEmitter
function onTouchO()
if (ball ~=nil) then
-- Turn on the particle effect for PartO
particle1:Clear()
particle1:Emit(10)
wait(1)
-- Disable the ball's visibility for Part)
ball.Position = ballSpawn.Position
ball.Transparency = 1
ball.Highlight.OutlineTransparency = 1
task.wait(3)
ball.Transparency = 0
ball.Highlight.OutlineTransparency = 0
end
end
function onTouchB()
if (ball ~=nil) then
-- Turn on the particle effect for PartB
particle2:Clear()
particle2:Emit(10)
wait(1)
-- Disable the ball's visibility for Part)
ball.Transparency = 1
ball.Highlight.OutlineTransparency = 1
end
end
ball.Touched:Connect(onTouchO)
ball.Touched:Connect(onTouchB)