Advertisement
OEAgamer1

Soccer Game Part.2

Feb 3rd, 2025
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. --Offbound Script
  2. local Ball = game.Workspace:WaitForChild("Ball")
  3. local Offbound1 = game.Workspace:WaitForChild("Offbound1")
  4. local Offbound2 = game.Workspace:WaitForChild("Offbound2")
  5. local Offbound3 = game.Workspace:WaitForChild("Offbound3")
  6. local Offbound4 = game.Workspace:WaitForChild("Offbound4")
  7. local OriginalPosition = Ball.Position
  8.  
  9. local function resetBall()
  10.     Ball.CFrame = CFrame.new(OriginalPosition)
  11. end
  12.  
  13. Offbound1.Touched:Connect(function(hit)
  14.     if hit == Ball then
  15.         resetBall()
  16.         Ball.Anchored = true
  17.         wait(3)
  18.         Ball.Anchored = false
  19.     end
  20. end)
  21.  
  22.  
  23. Offbound2.Touched:Connect(function(hit)
  24.     if hit == Ball then
  25.         resetBall()
  26.         Ball.Anchored = true
  27.         wait(3)
  28.         Ball.Anchored = false
  29.     end
  30. end)
  31.  
  32. Offbound3.Touched:Connect(function(hit)
  33.     if hit == Ball then
  34.         resetBall()
  35.         Ball.Anchored = true
  36.         wait(3)
  37.         Ball.Anchored = false
  38.     end
  39. end)
  40.  
  41. Offbound4.Touched:Connect(function(hit)
  42.     if hit == Ball then
  43.         resetBall()
  44.         Ball.Anchored = true
  45.         wait(3)
  46.         Ball.Anchored = false
  47.     end
  48. end)
  49.  
  50. ----------------------------------------
  51. --Kill after Goal Script
  52. local ball = game.Workspace:WaitForChild("Ball")
  53. local team1Goal = game.Workspace:WaitForChild("Team1")
  54. local team2Goal = game.Workspace:WaitForChild("Team2")
  55.  
  56.  
  57. local function killAllPlayers()
  58.     for _, player in ipairs(game.Players:GetPlayers()) do
  59.         if player.Character and player.Character:FindFirstChild("Humanoid") then
  60.             player.Character.Humanoid.Health = 0
  61.         end
  62.     end
  63. end
  64.  
  65. local function onBallTouch(otherPart)
  66.     if otherPart == ball then
  67.         killAllPlayers()
  68.     end
  69. end
  70.  
  71. team1Goal.Touched:Connect(onBallTouch)
  72. team2Goal.Touched:Connect(onBallTouch)
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement