Advertisement
OEAgamer1

Soccer Game

Jan 9th, 2024
6,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. -- ServerScriptService Script
  2. local Goal = game.ReplicatedStorage:WaitForChild("Goal")
  3. local Team1 = game.Workspace:WaitForChild("Team1")
  4. local Team2 = game.Workspace:WaitForChild("Team2")
  5. local Ball = game.Workspace:WaitForChild("Ball")
  6. local OriginalPosition = Ball.Position
  7.  
  8. local Points = {0, 0}
  9.  
  10. local function resetBall()
  11.     Ball.CFrame = CFrame.new(OriginalPosition)
  12. end
  13.  
  14. Team1.Touched:Connect(function(hit)
  15.     if hit == Ball then
  16.         Points[1] = Points[1] + 1
  17.         Goal:FireAllClients(Points)
  18.         resetBall()
  19.     end
  20. end)
  21.  
  22.  
  23. Team2.Touched:Connect(function(hit)
  24.     if hit == Ball then
  25.         Points[2] = Points[2] + 1
  26.         Goal:FireAllClients(Points)
  27.         resetBall()
  28.     end
  29. end)
  30.  
  31. game.Players.PlayerAdded:Connect(function(player)
  32.     Goal:FireClient(player, Points)
  33. end)
  34.  
  35. -------------------------------------------------------------------------------------------------------------------------------------
  36. --Textlabel LocalScript
  37. local Goal = game.ReplicatedStorage:WaitForChild("Goal")
  38.  
  39. local function SetPoints(points)
  40.     script.Parent.Text = points[1].." - "..points[2]
  41. end
  42.  
  43. Goal.OnClientEvent:Connect(function(points)
  44.     SetPoints(points)
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement