i spent an hour writing this code
local ServerStorage = game:GetService("ServerStorage")
local Racks = ServerStorage:WaitForChild("Racks")
local Ball = ServerStorage:WaitForChild("Ball")
--[[
Coding Sample
if GameRunning.Value == true and OOBValue.Value == false and Travel.Value == false and Scored.Value == false and ShotClock.Value ~= 0 then
end
]]
local function FireText(Text)
for _, Player in pairs(game.Players:GetPlayers()) do
local PlayerGui = Player:WaitForChild("PlayerGui")
local DisplayGui = PlayerGui:WaitForChild("Display")
local DisplayText = DisplayGui:WaitForChild("Display")
DisplayText.Text = Text
end
end
local function EnableGui(GuiName)
for _, Player in pairs(game.Players:GetPlayers()) do
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild(GuiName)
Gui.Enabled = true
end
end
local function DisableGui(GuiName)
for _, Player in pairs(game.Players:GetPlayers()) do
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild(GuiName)
Gui.Enabled = false
end
end
local function EnableGuiForPlayer(GuiName, Player)
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild(GuiName)
Gui.Enabled = true
end
local function DisableGuiForPlayer(GuiName, Player)
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild(GuiName)
Gui.Enabled = false
end
local function EnableGuiChildrenForPlayer(GuiName, Player, ChildName)
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild(GuiName)
local Object = Gui:WaitForChild(ChildName)
Object.Visible = true
end
local function DisableGuiChildrenForPlayer(GuiName, Player, ChildName)
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui = PlayerGui:WaitForChild(GuiName)
local Object = Gui:WaitForChild(ChildName)
Object.Visible = false
end
local CourtFolder = workspace["Game Court"]
local WallPartsFolder = CourtFolder.WallsPart
local GamePlayers = CourtFolder.GamePlayers
local GameValues = CourtFolder.GameValues
local GameRunning = GameValues.GameRunning
local Team1Folder = GamePlayers.Team1
local Team2Folder = GamePlayers.Team2
local ShotClockTimeRunning = GameValues.ShotClockTimeRunning
local Teleporters = CourtFolder.Teleporters
local Team1Tp = Teleporters.Team1Tp
local Team2Tp = Teleporters.Team2Tp
local TimeRunning = GameValues.TimeRunning
local SCViolation = GameValues.SCViolation
local BallTip = Teleporters.BallTP
local Team1Teleporters = Teleporters.Team1TP
local Team2Teleporters = Teleporters.Team2TP
local ShotClock = GameValues.ShotClock
local TeamBall = GameValues.TeamBall
local Travel = GameValues.Travel
local Time = GameValues.Time
local OOBValue = GameValues.OOB
local Scored = GameValues.Scored
local Removal = GameValues.Removal
local TimerActive = false
local PointValue = GameValues.PointValue
local Team1Score = GameValues.Team1Score
local Team2Score = GameValues.Team2Score
local TPBack = CourtFolder.TPBack
local AllowedToPass = GameValues.AllowedToPass
local Quarter = GameValues.Quarter
local Goals = CourtFolder.Goals
local Team1Goal = Goals:WaitForChild("Team1Goal")
local Team2Goal = Goals:WaitForChild("Team2Goal")
-- local PadsFolder = CourtFolder:WaitForChild("Pads")
-- local team1pads = PadsFolder.Team1
local ObjectsFolder = CourtFolder.Objects
-- local team2pads = PadsFolder.Team2
-- local Confirm = GameValues:WaitForChild("Confirmed")
-- local Agree = GameValues:WaitForChild("Agree")
-- local Refuse = GameValues:WaitForChild("Refuse")
-- local ScoreDebounce = GameValues.ScoreDebounce
local MaxPlayers = GameValues.MaxPlayers
local function CloneBall(Part)
local ClonedBall = Ball:Clone()
ClonedBall.Parent = workspace
ClonedBall.Ball.Position = Part.Position
ClonedBall.Ball.Values.CourtValue.Value = CourtFolder.Name
end
local function TeleportPlayers(Player, ActualPart, Speed)
-- Move Char
--[[ Sample Code
Player.Character:MoveTo(ActualPart.Position, ActualPart)
local Humanoid = Player.Character:WaitForChild("Humanoid")
Humanoid.WalkSpeed = Speed
]]
Player.Character:MoveTo(ActualPart.Position, ActualPart)
local Humanoid = Player.Character:WaitForChild("Humanoid")
Humanoid.WalkSpeed = Speed
end
local function SpeedPlayers(Speed)
for _, Player in pairs(game.Players:GetPlayers()) do
local Humanoid = Player.Character:WaitForChild("Humanoid")
Humanoid.WalkSpeed = Speed
end
end
while wait() do
print("working!")
if workspace.MainEvents.Winner.Value ~= "" then
FireText("Cleaning Up The Match!")
Team1Score.Value = 0
Team2Score.Value = 0
Removal.Value = true
Removal.Value = false
OOBValue.Value = false
Travel.Value = false
SCViolation.Value = false
TimeRunning.Value = false
ShotClockTimeRunning.Value = false
end
FireText("You Have 3 Minutes to Practice, enjoy!")
Time.Value = 180
TimeRunning.Value = true
Racks:Clone().Parent = workspace
FireText("")
repeat wait() until Time.Value == 0
TimeRunning.Value = false
FireText("Time's Up!")
workspace:WaitForChild("Racks"):Destroy()
EnableGui("Scoreboard")
wait(1)
FireText("")
if #game.Players:GetPlayers() == 2 then
for _, Player in pairs(game.Players:GetPlayers()) do
local RandomizedValue = Instance.new("NumberValue")
RandomizedValue.Parent = GamePlayers["Team"..math.random(1,2)]
RandomizedValue.Name = Player.Name
RandomizedValue.Value = math.random(1,4)
end
elseif #game.Players:GetPlayers() > 2 then
EnableGui("CaptainGUI")
-- For Team 1
for _, Player in pairs(game.Players:GetPlayers()) do
local AvailablePlayers = #Player
if AvailablePlayers > 0 then
local RandomizedPlayer = Player[math.random(1, AvailablePlayers)]
EnableGuiChildrenForPlayer("CaptainGUI", RandomizedPlayer, "ChoosePlayerForTeam1")
workspace.MainEvents.CaptainForTeam1.Value = RandomizedPlayer.Name
end
end
-- For Team 2
for _, Player in pairs(game.Players:GetPlayers()) do
local AvailablePlayers = #Player
if AvailablePlayers > 0 then
local RandomizedPlayer = Player[math.random(1, AvailablePlayers)]
-- EnableGuiChildrenForPlayer("CaptainGUI", RandomizedPlayer, "ChoosePlayerForTeam2")
workspace.MainEvents.CaptainForTeam2.Value = RandomizedPlayer.Name
end
end
else
for _, Player in pairs(game.Players:GetPlayers()) do
local RandomizedValue = Instance.new("NumberValue")
RandomizedValue.Parent = GamePlayers["Team"..math.random(1,2)]
RandomizedValue.Name = Player.Name
RandomizedValue.Value = math.random(1,4)
end
end
repeat wait() until workspace.PlayersForTeam1.Value == 4 and workspace.PlayersForTeam2.Value == 4
Removal.Value = true
DisableGui("CaptainGUI")
for _, Player in pairs(game.Players:GetPlayers()) do
if Team1Folder:FindFirstChild(Player.Name) then
TeleportPlayers(Player, GamePlayers.Team1[Player.Name].Value, 0)
elseif Team2Folder:FindFirstChild(Player.Name) then
TeleportPlayers(Player, GamePlayers.Team2[Player.Name].Value, 0)
end
end
Removal.Value = false
FireText("Welcome to NBA Phenom")
FireText("Shoot On the Hoops that are on the other side!")
FireText("First one with the Most Points Wins!")
for index = 3,1,-1 do
wait(1)
FireText("Game is Starting In "..index)
end
wait(1)
SpeedPlayers(16)
CloneBall(BallTip)
FireText("")
Quarter.Value = "1q"
Time.Value = 300
ShotClock.Value = 24
ShotClockTimeRunning.Value = true
TimeRunning.Value = true
GameRunning.Value = true
repeat wait() until Time.Value == 0 and AllowedToPass.Value == true
if GameRunning.Value == true and OOBValue.Value == false and Travel.Value == false and Scored.Value == false and ShotClock.Value ~= 0 then
Removal.Value = true
TimeRunning.Value = false
ShotClockTimeRunning.Value = false
Time.Value = 300
ShotClock.Value = 24
FireText("2nd Quarter!")
for number = 3,1,-1 do
wait(1)
FireText(number)
end
FireText("Go!")
wait(1)
FireText("")
Removal.Value = false
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
SpeedPlayers(16)
if TeamBall.Value == 1 then
CloneBall(Team2Tp)
elseif TeamBall.Value == 2 then
CloneBall(Team1Tp)
else
CloneBall(BallTip)
end
Quarter.Value = "2q"
TimeRunning.Value = true
ShotClock.Value = true
end
repeat wait() until Time.Value == 0 and AllowedToPass.Value == true
if GameRunning.Value == true and OOBValue.Value == false and Travel.Value == false and Scored.Value == false and ShotClock.Value ~= 0 then
Removal.Value = true
TimeRunning.Value = false
ShotClockTimeRunning.Value = false
Time.Value = 300
ShotClock.Value = 24
FireText("3rd Quarter!")
for number = 3,1,-1 do
wait(1)
FireText(number)
end
FireText("Go!")
wait(1)
FireText("")
Removal.Value = false
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
SpeedPlayers(16)
if TeamBall.Value == 1 then
CloneBall(Team2Tp)
elseif TeamBall.Value == 2 then
CloneBall(Team1Tp)
else
CloneBall(BallTip)
end
Quarter.Value = "3q"
TimeRunning.Value = true
ShotClock.Value = true
end
repeat wait() until Time.Value == 0 and AllowedToPass.Value == true
if GameRunning.Value == true and OOBValue.Value == false and Travel.Value == false and Scored.Value == false and ShotClock.Value ~= 0 then
Removal.Value = true
TimeRunning.Value = false
ShotClockTimeRunning.Value = false
Time.Value = 300
ShotClock.Value = 24
FireText("4th Quarter!")
for number = 3,1,-1 do
wait(1)
FireText(number)
end
FireText("Go!")
wait(1)
FireText("")
Removal.Value = false
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
SpeedPlayers(16)
if TeamBall.Value == 1 then
CloneBall(Team2Tp)
elseif TeamBall.Value == 2 then
CloneBall(Team1Tp)
else
CloneBall(BallTip)
end
Quarter.Value = "4q"
TimeRunning.Value = true
ShotClock.Value = true
if Time.Value == 0 then
if Team1Score.Value > Team2Score.Value then
FireText("Team 1 Won With the Points of "..Team1Score.Value)
workspace.MainEvents.Winner = "Team1"
elseif Team2Score.Value > Team1Score.Value then
FireText("Team 2 Won With the Points of "..Team2Score.Value)
workspace.MainEvents.Winner = "Team2"
end
end
end
end
if you need to ask for any lines of code ill be sure to screenshot it!
it printed but didn’t teleport me or anything