When A Touch Function Runs Every Other Functions of Touch Breaks

Everytime the ball hits the goal it should score and when it scores every other touch functions of the module script breaks

:confused:

I don’t know why is it doing this

Code

	local function TrueScore(hit, TeamName)
		print("worked")
		
		Scored.Value = true
		TimeRunning.Value = false
		hit.Equip.Disabled = true
		SpeedPlayers(0)
		Removal.Value = true
		FireText("Team"..TeamBall.Value.." Scores")
		TeamName.Value = TeamName.Value + 2
		
		repeat wait() until Scored.Value == true
		wait(2)
		for _, Player in pairs(game.Players:GetPlayers()) do
			if Team1Folder:FindFirstChild(Player.Name) then
				TeleportPlayers(Player, Team1Tp, 16)
			elseif Team2Folder:FindFirstChild(Player.Name) then
				TeleportPlayers(Player, Team2Tp, 16)
			end
		end
		Removal.Value = false
		ShotClock.Value = 24
		Scored.Value = false
		TimeRunning.Value = true
		if TeamBall.Value == 1 then
			CloneBall(Team2Tp)
		elseif TeamBall.Value == 2 then
			CloneBall(Team1Tp)
		else
			CloneBall(BallTip)
		end
		FireText("")
		
	end
	
	local function FalseScoring(hit, Name)
		print("worked")
		
		TimeRunning.Value = false
		hit.Equip.Disabled = true
		SpeedPlayers(0)
		Removal.Value = true
		FireText("False Scoring On "..Name)
		wait(2)
		for _, Player in pairs(game.Players:GetPlayers()) do
			if Team1Folder:FindFirstChild(Player.Name) then
				TeleportPlayers(Player, Team1Tp, 16)
			elseif Team2Folder:FindFirstChild(Player.Name) then
				TeleportPlayers(Player, Team2Tp, 16)
			end
		end
		Removal.Value = false
		ShotClock.Value = 24
		TimeRunning.Value = true
		if TeamBall.Value == 1 then
			CloneBall(Team2Tp)
		elseif TeamBall.Value == 2 then
			CloneBall(Team1Tp)
		else
			CloneBall(BallTip)
		end
		FireText("")
		
	end

	for _, ShootingPart in pairs(ShootingParts) do
		ShootingPart.Touched:Connect(function(hit)
			local Ball = hit.Parent
			if Ball:IsA("Tool") then
				if ShootingPart.Name == "Team1Goal" then
					if TeamBall.Value == 2 and Team2Score.Value < 22 then
						if not ShootDebounce then
							ShootDebounce = true
							TrueScore(hit, Team1Score)
							wait(1)
							Debounce = false
						end
					elseif TeamBall.Value == 2 and Team2Score.Value == 22 - 2 then
						if not ShootDebounce then
							Debounce = true
							GameFinished(TeamBall, Team2Score)
							wait(1)
							Debounce = false
					
						end
					elseif TeamBall.Value == 1 then
						if not ShootDebounce then
							Debounce = true
							FalseScoring(hit, hit.Values.BallHandler.Value)
							wait(2)
							Debounce = false
						end	
				end
			
				elseif ShootingPart.Name == "Team2Goal" then
						if TeamBall.Value == 1 and Team1Score.Value < 22 then
							if not ShootDebounce then
								ShootDebounce = true
								TrueScore(hit, Team1Score)
								wait(1)
								Debounce = false
							end
						elseif TeamBall.Value == 1 and Team1Score.Value == 22 - 2 then
							if not ShootDebounce then
								Debounce = true
								GameFinished(TeamBall, Team1Score)
								wait(1)
								Debounce = false
						
							end
						elseif TeamBall.Value == 2 then
							if not ShootDebounce then
								Debounce = true
								FalseScoring(hit, hit.Values.BallHandler.Value)
								wait(2)
								Debounce = false
							end	
					end
				end
			end
		end)
	end

Also the scoring does not work too

i fixed it lol the debounce was set not the shooting debounce

Please do not make posts that are identical/exactly the same.


If no one is answering your topics, perhaps you should take a look at your post and improve it further. Not many people want to help people who just dump code in a post and say “this isnt working”. You should try narrowing down the issue next time.

1 Like

yeah ill make sure to do that

30char