I am trying to make a script where a ball hits a part and when it does hit, the ball disappears and a particle turn on.
I have two of this scripts each in a part. The problem is when the ball hits that part, both of the scripts activate.
How do I fix this
-- SERVER SCRIPT LOCATED IN O
-- Get a reference to the ball and particle effect
---> veriables
local ball = game.Workspace:WaitForChild("Ball")
local particle = script.Parent.Attachment.ParticleEmitter
---> main
function onTouch()
if (ball ~=nil) then
-- Turn on the particle effect
particle:Clear()
particle:Emit(10)
wait(1)
-- Disable the ball's visibility
ball.Transparency = 1
ball.Highlight.OutlineTransparency = 1
end
end
-- Connect the collision function to the ball
ball.Touched:Connect(onTouch)