so i have a ball and have a script that detects when the ball touches a part but after a few times the script sometimes doesnt detect the ball
local ball = script.Parent
local BlueGoal = workspace.BlueGoal
local RedGoal = workspace.RedGoal
local RoundTeleport = workspace.RoundTeleport
local blueScore = game.ReplicatedStorage.BlueScore
local redScore = game.ReplicatedStorage.RedScore
BlueGoal.Touched:Connect(function(hit)
if hit == ball then
ball.Anchored = true
ball.Position = Vector3.new(60.366, 7.596, -16.019)
ball.Velocity = Vector3.new()
ball.AssemblyAngularVelocity = Vector3.new()
ball.Transparency = 1
ball.CanCollide = false
redScore.Value += 1
wait(5)
ball.CanCollide = true
ball.Transparency = 0
ball.Anchored = false
end
end)
RedGoal.Touched:Connect(function(hit)
if hit == ball then
ball.Anchored = true
ball.Position = Vector3.new(60.366, 7.596, -16.019)
ball.Velocity = Vector3.new()
ball.AssemblyAngularVelocity = Vector3.new()
ball.Transparency = 1
ball.CanCollide = false
blueScore.Value += 1
wait(5)
ball.CanCollide = true
ball.Transparency = 0
ball.Anchored = false
end
end)