I will send you the whole entire code and the code that just corelates to that part.
1000 lines of code of every client sided function in my game including the gamestart
--// Services
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local TweenService = game:GetService("TweenService")
--// Variables
local Click = SoundService:WaitForChild("Click")
local Camera = Workspace.CurrentCamera
local ClickUI = SoundService.ClickSound
local ErrorUI = SoundService.Error
local CameraShaker = require(ReplicatedStorage:WaitForChild("CameraShaker"))
--// Remotes
local TycoonRemotes = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Tycoon_Function_Remotes")
--// Player Data
local LocalPlayer = Players.LocalPlayer
--local TeamName = LocalPlayer.Team.Name
local PlayerGui = LocalPlayer.PlayerGui
--// Player UI
local Computer = PlayerGui:WaitForChild("Computer")
local Leave = Computer:WaitForChild("leave")
local TutorialText = PlayerGui:WaitForChild("Player").Dialog
--local SurfaceGui = LocalPlayer.PlayerGui:WaitForChild(TeamName)
--local exit = SurfaceGui:WaitForChild("MainFrame").Exit
local TextBox = PlayerGui:WaitForChild("Player").TextBox
local TextButton = PlayerGui:WaitForChild("Player").TextButton
local GameSFX = SoundService:WaitForChild("Gameday")
local CrowdAw = GameSFX:WaitForChild("CrowdAw")
local CrowdCheer = GameSFX:WaitForChild("CrowdCheer")
local teams = {
"Arizona Cats ",
"Atlanta Ducks",
"Baltimore Crows",
"Buffalo Stingers",
"Carolina Reapers" ,
"Chicago Polars",
"Cinncinati Bagels",
"Cleveland Dogs",
"Dallas Horses",
"Denver Suns",
"Detriot Lazers",
"Green Bay Slackers",
"Houston Flyers",
"Indianapolis Jokers",
"Jacksonville Jacks",
"Kansas City Reefs",
"Las Vegas Players",
"Los Angeles Lambs",
"Los Angeles Phone Chargers",
"Miami Fishermen",
"Minnesota Stockings",
"New England Geese",
"New Orleans Skys",
"New York Lightning ",
"New York Pancakes ",
"Philadelphia Birds ",
"Pittsburgh Burgalers ",
"San Francisco 21ers ",
"Seattle Crowns ",
"Tampa Bay Buckeyes ",
"Tennessee Thunder ",
"Washington Skinners"
}
local randomteam = teams[math.random(1, #teams)]
local StadiumAmbience = SoundService.Gameday["Stadium Ambience"]
local FadeFrame = PlayerGui:WaitForChild("Board_UI"):WaitForChild("FadeFrame")
local function BlurTween()
FadeFrame.Visible = true
local TweenService = game:GetService("TweenService")
local Frame = FadeFrame --This is the variable for the image. Change it if needed.
local TweenInfo = TweenInfo.new(
3, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local tween = TweenService:Create(Frame, TweenInfo, {BackgroundTransparency = 0})
tween:Play() --Plays the tween
end
local function UnBlurTween()
FadeFrame.Visible = true
local TweenService = game:GetService("TweenService")
local Frame = FadeFrame --This is the variable for the image. Change it if needed.
local TweenInfo = TweenInfo.new(
3, -- Time
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local tween = TweenService:Create(Frame, TweenInfo, {BackgroundTransparency = 1})
tween:Play() --Plays the tween
end
--// Functions
local function shakecam(shakeCf)
Camera.CFrame = Camera.CFrame * shakeCf
end
local renderPriority = Enum.RenderPriority.Camera.Value + 1
local CamShake = CameraShaker.new(renderPriority, shakecam)
local function typewrite(object, text)
for i = 1, #text, 1 do
object.Text = string.sub(text, 1, i)
Click:Play()
wait(0.08)
end
end
--// Camera Functions
local function CameraNormal()
local camera = Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom
end
--// Code
TycoonRemotes.CamRemoteTest.OnClientEvent:Connect(function(TeamName)
local Tycoon = Workspace:WaitForChild("Tycoon").Tycoons:WaitForChild(TeamName)
local Camera = Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
local CamTweenPC = TweenService:Create(Camera,TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = Tycoon:WaitForChild("PurchasedObjects").Office.ComputerCam.CFrame
})
CamTweenPC:Play()
-- Camera.CFrame = Tycoon:WaitForChild("PurchasedObjects").Office.ComputerCam.CFrame
Leave.Visible = true
Leave.MouseButton1Up:Connect(function(plr)
local Humanoid = LocalPlayer.Character.Humanoid
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
Leave.Visible = false
CameraNormal()
end)
-- PlayerGui.Computer.MainFrame.Visible = true
--local Text = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Dialogue.TextLabel
--typewrite(Text, "Welcome to the "..TeamName.." Tycoon!")
--wait(2)
--typewrite(Text, "This is where you can purchase items to help you survive!")
--wait(2)
--typewrite(Text, "You can also purchase")
--local CamTest = Workspace:WaitForChild("Tycoon").Tycoons.TeamName:WaitForChild("Purchases"):WaitForChild("WorkArea").ComputerCam
--CamTest.Transparency = 0
end)
--exit.MouseButton1Click:Connect(function(plr)
-- print("hi")
--end)
TycoonRemotes.Exit.OnClientEvent:Connect(function(plr)
CameraNormal()
end)
--// TweenService Variables
--local TweenInf = TweenInfo.new(5, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.StartTutorial.OnClientEvent:Connect(function(TeamName)
print("Tutorial in progress")
--// START TUTORIAL
local CameraFolder = Workspace.Tycoon.Tycoons:WaitForChild(TeamName).Essentials.TutorialCameras
--//Camera1
--Camera.CFrame = CameraFolder.Camera1.CFrame
Camera.CameraType = Enum.CameraType.Scriptable
local CamTween = TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = CameraFolder.Camera1.CFrame
})
CamTween:Play()
CamTween.Completed:Wait()
typewrite(TutorialText, "Welcome to the journey of building your dream football franchise!")
task.wait(3)
--//Camera2
--Camera.CFrame = CameraFolder.Camera2.CFrame
local CamTween2 = TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = CameraFolder.Camera2.CFrame
})
CamTween2:Play()
CamTween2.Completed:Wait()
Camera.CameraType = Enum.CameraType.Scriptable
typewrite(TutorialText, "Inside, you can access the computer and other things to upgrade your franchise, team, players and staff!")
--Camera.CFrame = CameraFolder.Camera2.CFrame
task.wait(3)
--// Camera 3
--Camera.CFrame = CameraFolder.Camera3.CFrame
Camera.CameraType = Enum.CameraType.Scriptable
local CamTween3 = TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = CameraFolder.Camera3.CFrame
})
CamTween3:Play()
CamTween3.Completed:Wait()
typewrite(TutorialText, "We have started your dream franchise with this decent team and alright football field")
--Camera.CFrame = CameraFolder.Camera2.CFrame
task.wait(3)
Camera.CameraType = Enum.CameraType.Scriptable
local CamTween4 = TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = CameraFolder.Camera4.CFrame
})
CamTween4:Play()
CamTween4.Completed:Wait()
typewrite(TutorialText, "Here is your gameplan board, where you can upgrade your run and pass game along side starting your current weeks game.")
--Camera.CFrame = CameraFolder.Camera2.CFrame
task.wait(3)
--// Camera 4
--Camera.CFrame = CameraFolder.Camera4.CFrame
Camera.CameraType = Enum.CameraType.Scriptable
local CamTween5= TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = CameraFolder.Camera5.CFrame
})
CamTween5:Play()
CamTween5.Completed:Wait()
--Camera.CFrame = CameraFolder.Camera2.CFrame
typewrite(TutorialText, "Now to start your franchise, choose your own team name!")
task.wait(2)
--//
TextBox.Visible = true
TextButton.Visible = true
TextButton.MouseButton1Up:Connect(function(player)
local TeamName1 = TextBox.Text
if TeamName1 ~= nil then
TextButton.Visible = false
TextBox.Visible = false
typewrite(TutorialText, "Nice choice! "..TeamName1.." is a great name!")
ReplicatedStorage.Remotes.UIRemotes.TeamPicked:FireServer(TeamName1)
task.wait(2)
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = LocalPlayer.Character.Humanoid
TextButton.Visible = false
TextBox.Visible = false
TutorialText.Visible = false
end
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.EndTutorial:FireServer(LocalPlayer)
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.UpdateSigns.OnClientEvent:Connect(function(plr)
local TeamName =LocalPlayer.ValuesGame.TeamName.Value
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.UpdateSigns:FireServer(TeamName)
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Pedestrian1.OnClientEvent:Connect(function(player)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Pedestrian1:FireServer(player)
end)
--// WHITE BOARD ACTIONS
local BoardUI = LocalPlayer.PlayerGui:WaitForChild("Board_UI")
local MainFrame = BoardUI.MainFrame
local PassFrame = MainFrame.PassFrame:GetChildren()
local PassF = MainFrame.PassFrame
local RunF = MainFrame.RunGame
local RunFrame = MainFrame.RunGame:GetChildren()
local PassGameValue = LocalPlayer:WaitForChild("ValuesGame").Team.PassGame
local RunGameValue = LocalPlayer:WaitForChild("ValuesGame").Team.RunGame
local Winrate = MainFrame.WinRate
local PracticeStatus = MainFrame.PracticeStatus
--local PassAttributeCost = MainFrame.PassPurchase.AttributeCost
--PassAttributeCost.Value *= PassGameValue.Value
local CurrentPassCost = LocalPlayer.ValuesGame.Team.PassGameCost.Value
MainFrame.PassPurchase.PurchaseLabel.Text = "Purchase 1 Pass Attribute For ".. CurrentPassCost .. " Cash?"
--//Buttons and stuff
local Exit = MainFrame.Exit
ReplicatedStorage.Remotes.UIRemotes.UI_BoardStart.OnClientEvent:Connect(function(TeamName)
local Tycoon = Workspace:WaitForChild("Tycoon").Tycoons:WaitForChild(TeamName)
local Board = Tycoon.PurchasedObjects.Office.Whiteboard
local BoardCam = Board.BoardCamera
local PlayerName = LocalPlayer.Name
local Owner = Tycoon.TycoonInfo.Owner
if Owner.Value.Name == PlayerName then
Camera.CameraType = Enum.CameraType.Scriptable
--// Some Presets
MainFrame.TeamName.Text = LocalPlayer.ValuesGame.TeamName.Value
--// Labels
--//
local CamTweenBoard = TweenService:Create(Camera,TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = BoardCam.CFrame
})
SoundService.Chalk:Play()
CamTweenBoard:Play()
CamTweenBoard.Completed:Wait()
MainFrame.Visible = true
end
end)
local mainExit = nil
local mainPass = nil
local mainPassPurch = nil
local mainPassDecline = nil
local mainRun = nil
local mainRunPurch = nil
local mainRunDecline = nil
local playercustom = nil
local startgame = nil
local startgamedecline = nil
local actualstartgame = nil
ReplicatedStorage.Remotes.UIRemotes.UI_BoardStart.OnClientEvent:Connect(function(TeamName, ...) -- Every time this event fires
if mainExit then mainExit:Disconnect() end
if mainPass then mainPass:Disconnect() end
if mainPassPurch then mainPassPurch:Disconnect() end
if mainPassDecline then mainPassDecline:Disconnect() end
if mainRun then mainRun:Disconnect() end
if mainRunPurch then mainRunPurch:Disconnect() end
if mainRunDecline then mainRunDecline:Disconnect() end
if playercustom then playercustom :Disconnect() end
if startgame then startgame:Disconnect() end
if startgamedecline then startgamedecline:Disconnect() end
if actualstartgame then actualstartgame:Disconnect() end
-- so and so forth
mainExit = MainFrame.Exit.MouseButton1Click:Connect(function(plr, ...) -- A new connection here will be established (it does not disconnect old connections)
print(...) -- this will print for every new and pre-existing connection that's been created
ClickUI:Play()
MainFrame.Visible = false
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = LocalPlayer.Character.Humanoid
end)
mainPass = MainFrame.PassButton.MouseButton1Click:Connect(function(plr, ...)
ClickUI:Play()
MainFrame.PassPurchase.Visible = true
print(...)
end)
mainPassPurch = MainFrame.PassPurchase.Purchase.MouseButton1Click:Connect(function(plr, ...)
if LocalPlayer.ValuesGame.Team.PassGame.Value >= 10 then
print("Pass Game Maxed Out")
MainFrame.PassPurchase.PurchaseLabel.Text = "Your pass attributes are maxed out!"
task.wait(3)
MainFrame.PassPurchase.PurchaseLabel.Text = "Purchase 1 Pass Attribute For ".. CurrentPassCost .. " Cash?"
else
if LocalPlayer.leaderstats.Cash.Value <= CurrentPassCost then
ErrorUI:Play()
MainFrame.PassPurchase.PurchaseLabel.Text = "You cannot afford an attribute!"
task.wait(3)
MainFrame.PassPurchase.PurchaseLabel.Text = "Purchase 1 Pass Attribute For ".. CurrentPassCost .. " Cash?"
else
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.White_Board.PurchasePassAttribute:FireServer(CurrentPassCost,TeamName)
print("" ..LocalPlayer.Name.. " Purchased an attribute for ".. CurrentPassCost .. "")
MainFrame.PassPurchase.Visible = false
SoundService.PurchaseCompleted:Play()
-- MainFrame.PassPurchase.Visible = false
end
end
end)
mainPassDecline = MainFrame.PassPurchase.Decline.MouseButton1Click:Connect(function(plr, ...)
ClickUI:Play()
MainFrame.PassPurchase.Visible = false
end)
mainRun = MainFrame.RunButton.MouseButton1Click:Connect(function(plr, ...)
ClickUI:Play()
MainFrame.RunPurchase.Visible = true
end)
mainRunPurch = MainFrame.RunPurchase.Purchase.MouseButton1Click:Connect(function(plr, ...)
if LocalPlayer.ValuesGame.Team.RunGame.Value >= 10 then
print("Pass Game Maxed Out")
MainFrame.RunPurchase.PurchaseLabel.Text = "Your run attributes are maxed out!"
task.wait(3)
MainFrame.RunPurchase.PurchaseLabel.Text = "Purchase 1 Run Attribute For ".. CurrentPassCost .. " Cash?"
else
if LocalPlayer.leaderstats.Cash.Value <= CurrentPassCost then
ErrorUI:Play()
MainFrame.RunPurchase.PurchaseLabel.Text = "You cannot afford an attribute!"
task.wait(3)
MainFrame.RunPurchase.PurchaseLabel.Text = "Purchase 1 Run Attribute For ".. CurrentPassCost .. " Cash?"
else
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.White_Board.PurchaseRunAttribute:FireServer(CurrentPassCost,TeamName)
print("" ..LocalPlayer.Name.. " Purchased an attribute for ".. CurrentPassCost .. "")
MainFrame.RunPurchase.Visible = false
SoundService.PurchaseCompleted:Play()
-- MainFrame.PassPurchase.Visible = false
end
end
end)
mainRunDecline = MainFrame.RunPurchase.Decline.MouseButton1Click:Connect(function(plr, ...)
ClickUI:Play()
MainFrame.RunPurchase.Visible = false
end)
playercustom = MainFrame.CustomizeTeam.MouseButton1Click:Connect(function(plr, ...)
ClickUI:Play()
--LocalPlayer.PlayerGui.Player_Customization.NextButton.Visible = true
MainFrame.Visible = false
TycoonRemotes.Player_Customization.StartEvent:FireServer(TeamName)
end)
startgame = MainFrame.StartGame.MouseButton1Click:Connect(function(plr, ...)
ClickUI:Play()
MainFrame.Gamestart.Visible = true
end)
startgamedecline = MainFrame.Gamestart.Decline.MouseButton1Click:Connect(function(plr, ...)
ClickUI:Play()
MainFrame.Gamestart.Visible = false
end)
local activeConnections = {}
local buttonClicked = false
local connection
-- Function to manage connections
local function addConnection(conn)
table.insert(activeConnections, conn)
end
local function cleanupConnections()
for _, conn in ipairs(activeConnections) do
if conn.Connected then
conn:Disconnect()
end
end
activeConnections = {}
end
-- Function to reset the game state
local function resetGameState()
PlayerGui.Player.GameUI.Visible = false
PlayerGui.Player.Skip.Visible = false
PlayerGui.Player.Skip.Value.Value = false
PlayerGui.Player.CoinFlip.Visible = false
TutorialText.Text = ""
TutorialText.Visible = false
buttonClicked = false
end
-- Skip Button Logic (connected once)
local skipConnection
-- Ensure Skip Button Logic is connected only once
if not skipConnection then
skipConnection = PlayerGui.Player.Skip.MouseButton1Click:Connect(function()
PlayerGui.Player.GameUI.Visible = true
PlayerGui.Player.Skip.Visible = false
PlayerGui.Player.Skip.Value.Value = true
ClickUI:Play()
typewrite(TutorialText, "")
TutorialText.Text = ""
TutorialText.Visible = false
CameraNormal()
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.StartGame:FireServer()
SoundService.Gameday:WaitForChild("Spotlights"):Stop()
end)
addConnection(skipConnection)
end
-- Main Game Logic
MainFrame.Gamestart.Yes.MouseButton1Click:Connect(function()
if buttonClicked then return end
buttonClicked = true
cleanupConnections() -- Clean up old connections
MainFrame.Gamestart.Visible = false
MainFrame.Visible = false
print("Sending event to server")
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote:FireServer()
-- Connection to handle game start
local OfficialGameRemote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Tycoon_Function_Remotes"):WaitForChild("OfficialGameRemote")
connection = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote.OnClientEvent:Connect(function(player)
print("connection1")
if LocalPlayer.ValuesGame.Practice.Value == false and LocalPlayer.ValuesGame.Game.Value == false then
ClickUI:Play()
BlurTween()
MainFrame.Visible = false
task.wait(5)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.FetchTeamData:FireServer(player)
-- Fetch team data logic
local connection2 = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.FetchTeamData.OnClientEvent:Connect(function(Teamname)
local GameCameras = Workspace:WaitForChild("Tycoon").Tycoons:WaitForChild(Teamname).Essentials.GamedayCameras
Camera.CameraType = Enum.CameraType.Scriptable
local CamTween1 = TweenService:Create(Camera, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
CFrame = GameCameras.Camera1.CFrame
})
CamTween1:Play()
StadiumAmbience:Play()
CamTween1.Completed:Wait()
TutorialText.Text = ""
TutorialText.Visible = true
UnBlurTween()
task.wait(3)
PlayerGui.Player.Skip.Visible = true
-- Coin Flip Logic
local CoinFlip = PlayerGui.Player.CoinFlip
CoinFlip.Visible = true
local headsConnection = CoinFlip.Heads.MouseButton1Click:Connect(function()
CoinFlip.Visible = false
ClickUI:Play()
local chance = math.random(1, 100)
if chance > 50 then
CoinFlip.Flip.Value = true
CrowdCheer:Play()
TutorialText.Visible = true
typewrite(TutorialText, "It seems the " .. LocalPlayer.ValuesGame.TeamName.Value .. " won the coin toss!")
else
CoinFlip.Flip.Value = true
CrowdAw:Play()
TutorialText.Visible = true
typewrite(TutorialText, "The " .. LocalPlayer.ValuesGame.TeamName.Value .. " lost the coin toss.")
end
end)
addConnection(headsConnection)
local tailsConnection = CoinFlip.Tails.MouseButton1Click:Connect(function()
CoinFlip.Visible = false
ClickUI:Play()
local chance = math.random(1, 100)
if chance > 50 then
CoinFlip.Flip.Value = true
CrowdCheer:Play()
TutorialText.Visible = true
typewrite(TutorialText, "It seems the " .. LocalPlayer.ValuesGame.TeamName.Value .. " won the coin toss!")
else
CoinFlip.Flip.Value = true
CrowdAw:Play()
TutorialText.Visible = true
typewrite(TutorialText, "The " .. LocalPlayer.ValuesGame.TeamName.Value .. " lost the coin toss.")
end
end)
addConnection(tailsConnection)
local flipChangeConnection = CoinFlip.Flip.Changed:Connect(function()
task.wait(3)
local CamTween4 = TweenService:Create(Camera, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
CFrame = GameCameras.Camera4.CFrame
})
CamTween4:Play()
typewrite(TutorialText, "The game is underway here at " .. LocalPlayer.ValuesGame.TeamName.Value .. " field!")
task.wait(3)
TutorialText.Visible = false
CameraNormal()
if not PlayerGui.Player.Skip.Value.Value then
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.StartGame:FireServer()
PlayerGui.Player.GameUI.Visible = true
PlayerGui.Player.GameUI.TimeFrame.Quarter.Value += 1
end
-- Reset the game state
resetGameState()
end)
addConnection(flipChangeConnection)
end)
addConnection(connection2)
end
end)
addConnection(connection)
end)
end)
--// [[WHITE BOARD]]
LocalPlayer.ValuesGame.Team.Week.Changed:Connect(function(plr)
MainFrame.WeekLabel.Text = "Week ".. LocalPlayer.ValuesGame.Team.Week.Value ..""
MainFrame.StartGame.Text = "Start Week ".. LocalPlayer.ValuesGame.Team.Week.Value.." Game"
MainFrame.Gamestart.Label.Text = "Are you sure you want to start your week "..LocalPlayer.ValuesGame.Team.Week.Value.." game?"
end)
MainFrame.WeekLabel.Text = "Week ".. LocalPlayer.ValuesGame.Team.Week.Value ..""
MainFrame.StartGame.Text = "Start Week ".. LocalPlayer.ValuesGame.Team.Week.Value.." Game"
MainFrame.Gamestart.Label.Text = "Are you sure you want to start your week "..LocalPlayer.ValuesGame.Team.Week.Value.." game?"
local function PassLabel()
if LocalPlayer.ValuesGame.Team.PassGame.Value <= 4 then
MainFrame.PassLabel1.Text = "Needs work"
MainFrame.PassLabel1.TextColor3 = Color3.fromRGB(255, 0, 0)
elseif LocalPlayer.ValuesGame.Team.PassGame.Value >= 5 then
MainFrame.PassLabel1.Text = "Good"
MainFrame.PassLabel1.TextColor3 = Color3.fromRGB(0, 255, 0)
end
end
local function RunLabel()
if LocalPlayer.ValuesGame.Team.RunGame.Value <= 4 then
MainFrame.RunGameLabel2.Text = "Needs work"
MainFrame.RunGameLabel2.TextColor3 = Color3.fromRGB(255, 0, 0)
elseif LocalPlayer.ValuesGame.Team.RunGame.Value >= 5 then
MainFrame.RunGameLabel2.Text = "Good"
MainFrame.RunGameLabel2.TextColor3 = Color3.fromRGB(0, 255, 0)
end
end
local function WinRateLoad()
if LocalPlayer.ValuesGame.Team.Practice.Value <= 0 then
PracticeStatus.Text = "Your team probably needs more practice to have a better chance of winning."
Winrate.Text = "Chance of winning : Low"
Winrate.TextColor3 = Color3.fromRGB(255, 85, 0)
elseif LocalPlayer.ValuesGame.Team.Practice.Value <= 3 then
PracticeStatus.Text = "Your team is slightly warmed up."
Winrate.Text = "Chance of winning : Medium"
Winrate.TextColor3 = Color3.fromRGB(255, 255, 0)
elseif LocalPlayer.ValuesGame.Team.Practice.Value <= 5 then
PracticeStatus.Text = "Your team is warmed up."
Winrate.Text = "Chance of winning : High"
Winrate.TextColor3 = Color3.fromRGB(0, 255, 0)
elseif LocalPlayer.ValuesGame.Team.Practice.Value <= 11 then
PracticeStatus.Text = "Your team is very warmed up and ready to play their next game. đ„"
Winrate.Text = "Chance of winning : Very High"
Winrate.TextColor3 = Color3.fromRGB(0, 255, 0)
end
end
LocalPlayer.ValuesGame.Team.Practice.Changed:Connect(function(plr)
WinRateLoad()
end)
--[PASS ATTRIBUTES]
--// Pass Attribute Presets
-- this code determines if the attributes color is red or green based on how many attributes they have, in this case the # is 4 so when it is higher than 4 the attributes turn green.
--// PASS ATTRIBUTES
local function CloneAttributes()
local Cloned_ATT = PassF.Attribute:Clone()
Cloned_ATT.Parent = PassF
MainFrame.PassPurchase.PurchaseLabel.Text = "Purchase 1 Pass Attribute For ".. CurrentPassCost .. " Cash?"
task.wait(1)
end
local function CloneAttributesRun()
local Cloned_ATT1 = RunF.Attribute:Clone()
Cloned_ATT1.Parent = RunF
MainFrame.RunPurchase.PurchaseLabel.Text = "Purchase 1 Run Attribute For ".. CurrentPassCost .. " Cash?"
task.wait(1)
end
local function OnJoinRefreshPassAttributes()
for i,v in pairs(PassFrame) do
--CurrentPassCost += 1000
if v:IsA("Frame") then
if v.Name == "Attribute" then
local amnt = PassGameValue.Value --Number of times it will clone
local n = PassGameValue.Value --how much times
for i = 1, n do
local clone = v:clone()
clone.Parent = PassF;
end
v:Destroy()
end
end
end
end
local function OnJoinRefreshRunAttributes()
for i,v in pairs(RunFrame) do
--CurrentPassCost += 1000
if v:IsA("Frame") then
if v.Name == "Attribute" then
local amnt = RunGameValue.Value --Number of times it will clone
local n = RunGameValue.Value --how much times
for i = 1, n do
local clone = v:clone()
clone.Parent = RunF;
end
v:Destroy()
end
end
end
end
for i,v in pairs(PassFrame) do --// PASS RED AND GREEN ATTRIBUTES
if v:IsA("Frame") then
if v.Name == "Attribute" then
if PassGameValue.Value <= 4 then
v.Red.Enabled = true
v.Green.Enabled = false
elseif PassGameValue.Value >= 4 then
v.Red.Enabled = false
v.Green.Enabled = true
end
end
end
end
for i,v in pairs(RunFrame) do --// PASS RED AND GREEN ATTRIBUTES
if v:IsA("Frame") then
if v.Name == "Attribute" then
if RunGameValue.Value <= 4 then
v.Red.Enabled = true
v.Green.Enabled = false
elseif RunGameValue.Value >= 4 then
v.Red.Enabled = false
v.Green.Enabled = true
end
end
end
end
PassGameValue.Changed:Connect(function(plr) -- Pass changed
--CloneAttributes()
--RefreshPassAttributes()
end)
RunGameValue.Changed:Connect(function(plr) -- Run changed
--RefreshRunAttributes()
end)
WinRateLoad()
OnJoinRefreshPassAttributes()
PassLabel()
OnJoinRefreshRunAttributes()
RunLabel()
--RefreshRunAttributes()
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.White_Board.PurchasePassAttribute.OnClientEvent:Connect(function(plr)
MainFrame.PassPurchase.Visible = false
SoundService.PurchaseCompleted:Play()
MainFrame.PassPurchase.Visible = false
CloneAttributes()
PassLabel()
--CloneAttributes()
--MainFrame.PassFrame.Attribute:Destroy()
-- RefreshPassAttributes()
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.White_Board.PurchaseRunAttribute.OnClientEvent:Connect(function(plr)
MainFrame.RunPurchase.Visible = false
SoundService.PurchaseCompleted:Play()
MainFrame.RunPurchase.Visible = false
CloneAttributesRun()
RunLabel()
--CloneAttributes()
--MainFrame.PassFrame.Attribute:Destroy()
-- RefreshPassAttributes()
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.White_Board.PurchaseNo.OnClientEvent:Connect(function(plr)
ErrorUI:Play()
MainFrame.PassPurchase.PurchaseLabel.Text = "You cannot afford an attribute!"
--task.wait(3)
--MainFrame.PassPurchase.PurchaseLabel.Text = "Purchase 1 Pass Attribute For ".. CurrentPassCost .. " Cash?"
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.White_Board.PurchaseNo1.OnClientEvent:Connect(function(plr)
ErrorUI:Play()
MainFrame.RunPurchase.PurchaseLabel.Text = "You cannot afford an attribute!"
--task.wait(3)
--MainFrame.PassPurchase.PurchaseLabel.Text = "Purchase 1 Pass Attribute For ".. CurrentPassCost .. " Cash?"
end)
--// HOME TOUCHDOWN
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.Touchdown.OnClientEvent:Connect(function(plr)
SoundService.Gameday.CrowdCheer:Play()
PlayerGui.Player.GameUI.HomeScore.Score.Value += 7
PlayerGui.Player.GameUI.Context.Text = "Your team scored a touchdown!"
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
end)
--// AWAY TOUCHDOWN
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.OtherTeamTouchdown.OnClientEvent:Connect(function(plr)
SoundService.Gameday.CrowdAw:Play()
PlayerGui.Player.GameUI.AwayScore.Score.Value += 7
PlayerGui.Player.GameUI.Context.Text = "The other team scored a touchdown!"
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.AnotherPlay.OnClientEvent:Connect(function(plr)
SoundService.Gameday.CrowdAw:Play()
PlayerGui.Player.GameUI.Context.Text = "The other team stopped you!"
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.OtherTeamPlayStop.OnClientEvent:Connect(function(plr)
SoundService.Gameday.CrowdCheer:Play()
PlayerGui.Player.GameUI.Context.Text = "You stopped the other team from scoring!"
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
end)
--// HOME SCORE
PlayerGui.Player.GameUI.HomeScore.Score.Changed:Connect(function(plr)
PlayerGui.Player.GameUI.HomeScore.Text = PlayerGui.Player.GameUI.HomeScore.Score.Value
end)
--// AWAY SCORE
PlayerGui.Player.GameUI.AwayScore.Score.Changed:Connect(function(plr)
PlayerGui.Player.GameUI.AwayScore.Text = PlayerGui.Player.GameUI.AwayScore.Score.Value
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.NextQuarter.OnClientEvent:Connect(function(plr)
PlayerGui.Player.GameUI.TimeFrame.Quarter.Value += 1
end)
PlayerGui.Player.GameUI.TimeFrame.Quarter.Changed:Connect(function(plr)
if PlayerGui.Player.GameUI.TimeFrame.Quarter.Value == 5 then
PlayerGui.Player.GameUI.TimeFrame.Text = ""
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.GameOver:FireServer(plr)
else
PlayerGui.Player.GameUI.TimeFrame.Text = "Q"..PlayerGui.Player.GameUI.TimeFrame.Quarter.Value..""
PlayerGui.Player.GameUI.Context.Text = "NEXT QUARTER!"
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
end
end)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.GameOver.OnClientEvent:Connect(function(plr)
PlayerGui.Player.GameUI.Context.Text = "Game over!"
task.wait(10)
-- Game results
if PlayerGui.Player.GameUI.HomeScore.Score.Value > PlayerGui.Player.GameUI.AwayScore.Score.Value then
local HomeScoreValue = PlayerGui.Player.GameUI.HomeScore.Score.Value
PlayerGui.Player.GameUI.Context.Text = "You won!"
CrowdCheer:Play()
CamShake:Start()
TycoonRemotes.Gametime.Gamewon:FireServer(HomeScoreValue)
CamShake:Shake(CameraShaker.Presets.Explosion)
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
PlayerGui.Player.GameUI.Visible = false
elseif PlayerGui.Player.GameUI.HomeScore.Score.Value < PlayerGui.Player.GameUI.AwayScore.Score.Value then
local HomeScoreValue = PlayerGui.Player.GameUI.HomeScore.Score.Value
PlayerGui.Player.GameUI.Context.Text = "You lost!"
CrowdAw:Play()
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
PlayerGui.Player.GameUI.Visible = false
TycoonRemotes.Gametime.Gamelost:FireServer(HomeScoreValue)
elseif PlayerGui.Player.GameUI.HomeScore.Score.Value == PlayerGui.Player.GameUI.AwayScore.Score.Value then
PlayerGui.Player.GameUI.Context.Text = "TIE!"
SoundService.Gameday.fart:Play()
task.wait(3)
PlayerGui.Player.GameUI.Context.Text = ""
PlayerGui.Player.GameUI.Visible = false
end
task.wait(3)
StadiumAmbience:Stop()
end)
just this part
local activeConnections = {}
local buttonClicked = false
local connection
-- Function to manage connections
local function addConnection(conn)
table.insert(activeConnections, conn)
end
local function cleanupConnections()
for _, conn in ipairs(activeConnections) do
if conn.Connected then
conn:Disconnect()
end
end
activeConnections = {}
end
-- Function to reset the game state
local function resetGameState()
PlayerGui.Player.GameUI.Visible = false
PlayerGui.Player.Skip.Visible = false
PlayerGui.Player.Skip.Value.Value = false
PlayerGui.Player.CoinFlip.Visible = false
TutorialText.Text = ""
TutorialText.Visible = false
buttonClicked = false
end
-- Skip Button Logic (connected once)
local skipConnection
-- Ensure Skip Button Logic is connected only once
if not skipConnection then
skipConnection = PlayerGui.Player.Skip.MouseButton1Click:Connect(function()
PlayerGui.Player.GameUI.Visible = true
PlayerGui.Player.Skip.Visible = false
PlayerGui.Player.Skip.Value.Value = true
ClickUI:Play()
typewrite(TutorialText, "")
TutorialText.Text = ""
TutorialText.Visible = false
CameraNormal()
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.StartGame:FireServer()
SoundService.Gameday:WaitForChild("Spotlights"):Stop()
end)
addConnection(skipConnection)
end
-- Main Game Logic
MainFrame.Gamestart.Yes.MouseButton1Click:Connect(function()
if buttonClicked then return end
buttonClicked = true
cleanupConnections() -- Clean up old connections
MainFrame.Gamestart.Visible = false
MainFrame.Visible = false
print("Sending event to server")
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote:FireServer()
-- Connection to handle game start
local OfficialGameRemote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Tycoon_Function_Remotes"):WaitForChild("OfficialGameRemote")
connection = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote.OnClientEvent:Connect(function(player)
print("connection1")
if LocalPlayer.ValuesGame.Practice.Value == false and LocalPlayer.ValuesGame.Game.Value == false then
ClickUI:Play()
BlurTween()
MainFrame.Visible = false
task.wait(5)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.FetchTeamData:FireServer(player)
-- Fetch team data logic
local connection2 = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.FetchTeamData.OnClientEvent:Connect(function(Teamname)
local GameCameras = Workspace:WaitForChild("Tycoon").Tycoons:WaitForChild(Teamname).Essentials.GamedayCameras
Camera.CameraType = Enum.CameraType.Scriptable
local CamTween1 = TweenService:Create(Camera, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
CFrame = GameCameras.Camera1.CFrame
})
CamTween1:Play()
StadiumAmbience:Play()
CamTween1.Completed:Wait()
TutorialText.Text = ""
TutorialText.Visible = true
UnBlurTween()
task.wait(3)
PlayerGui.Player.Skip.Visible = true
-- Coin Flip Logic
local CoinFlip = PlayerGui.Player.CoinFlip
CoinFlip.Visible = true
local headsConnection = CoinFlip.Heads.MouseButton1Click:Connect(function()
CoinFlip.Visible = false
ClickUI:Play()
local chance = math.random(1, 100)
if chance > 50 then
CoinFlip.Flip.Value = true
CrowdCheer:Play()
TutorialText.Visible = true
typewrite(TutorialText, "It seems the " .. LocalPlayer.ValuesGame.TeamName.Value .. " won the coin toss!")
else
CoinFlip.Flip.Value = true
CrowdAw:Play()
TutorialText.Visible = true
typewrite(TutorialText, "The " .. LocalPlayer.ValuesGame.TeamName.Value .. " lost the coin toss.")
end
end)
addConnection(headsConnection)
local tailsConnection = CoinFlip.Tails.MouseButton1Click:Connect(function()
CoinFlip.Visible = false
ClickUI:Play()
local chance = math.random(1, 100)
if chance > 50 then
CoinFlip.Flip.Value = true
CrowdCheer:Play()
TutorialText.Visible = true
typewrite(TutorialText, "It seems the " .. LocalPlayer.ValuesGame.TeamName.Value .. " won the coin toss!")
else
CoinFlip.Flip.Value = true
CrowdAw:Play()
TutorialText.Visible = true
typewrite(TutorialText, "The " .. LocalPlayer.ValuesGame.TeamName.Value .. " lost the coin toss.")
end
end)
addConnection(tailsConnection)
local flipChangeConnection = CoinFlip.Flip.Changed:Connect(function()
task.wait(3)
local CamTween4 = TweenService:Create(Camera, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
CFrame = GameCameras.Camera4.CFrame
})
CamTween4:Play()
typewrite(TutorialText, "The game is underway here at " .. LocalPlayer.ValuesGame.TeamName.Value .. " field!")
task.wait(3)
TutorialText.Visible = false
CameraNormal()
if not PlayerGui.Player.Skip.Value.Value then
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.StartGame:FireServer()
PlayerGui.Player.GameUI.Visible = true
PlayerGui.Player.GameUI.TimeFrame.Quarter.Value += 1
end
-- Reset the game state
resetGameState()
end)
addConnection(flipChangeConnection)
end)
addConnection(connection2)
end
end)
addConnection(connection)
end)