I am trying to make a tennis game and I am currently working on the point system. For context imagine a tennis court and two invisible walls behind each player. I am scripting it so that if the tennis ball touches one of these walls, it means the ball got passed the player so the point should be awarded to the opposing player. I am having trouble specifically with what to put inside the second while loop. My idea is to use the “repeat wait() until” the ball touches one of these walls. However, I do not believe this is the best practice and there is a better system out there. But if I don’t have that “repeat wait() until” then the second loop will run indefinitely. Don’t worry about out of bounds or other rules right now.
function runGame()
local redPoints=0
local bluePoints=0
local redSetsWon=0
local blueSetsWon=0
while redSetsWon<2 or blueSetsWon<2 do
while bluePoints<4 or redPoints<4 do
repeat wait() until *tennis ball touches a wall*
tennisBall.Touched:Connect(function(Hit)
if Hit.Name == "BlueWall" then
--give point to red
else if Hit.Name == "RedWall" then
--give point to blue
end
end)
end
end
end