Help With Touch Event

I am making a soccer system. If the ball goes into the a red goal (partO) then and particle goes off and same thing with the blue goal (partB).

The problem is the script is not detecting the ball touching the goal when the ball is

1 Like

What does it print out exactly, that’s what I am looking for.

Nothing printes-------------------------------

Didn’t you say it prints with the script I gave you? I don’t think I’m following…

I found this but it sill won’t work but this is an idea of how can someone fix it

-- SERVER SCRIPT LOCATED IN SERVERSCRIPTSERVICE
local bladeBall = workspace.BladeBall
local onangeHitBox = workspace.OnangeHitBox
local blueHitBox = workspace.BlueHitBox
local bladeBallSpawn = workspace.BladeBallSpawn
local particleO = onangeHitBox.Attachment.ParticleEmitter
local particleB = blueHitBox.Attachment.ParticleEmitter

-- Function to reset the ball's position
local function resetBallPosition()
	bladeBall.Transparency = 1
	bladeBall.Highlight.OutlineTransparency = 1
	bladeBall.CFrame = bladeBallSpawn.CFrame
	wait(3)
	bladeBall.Highlight.OutlineTransparency = 0
	bladeBall.Transparency = 0
end

-- Function to make a particle effect for PartO
local function createParticleO()
	particleO:Clear()
	particleO:Emit(1) -- number of particles emitted
end

-- Function to make a particle effect for PartB
local function createParticleB()
	particleB:Clear()
	particleB:Emit(1) -- number of particles emitted
end

-- Ball touch events
while wait(1) do
	local function GetTouchingParts(part)
		local connection = bladeBall.Touched:Connect(function() end)
		local results = part:GetTouchingParts()
		connection:Disconnect()
		return results
	end

	local results = GetTouchingParts(workspace.OnangeHitBox)
	for i, v in pairs(results) do
		if v == onangeHitBox then
			createParticleO()
			resetBallPosition()
		elseif v == blueHitBox then
			createParticleB()
			resetBallPosition()
		end
	end
end
1 Like

Never mind I figured it out---------

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.