dav2777
(dav2777)
September 10, 2023, 3:46pm
#1
Im currently making a soccer game, that has an intermission, loads the stadium, first half, break time, start of second half, the second half and then the end of the game. Alll in that order. Everything works, except, for the part: second half starting and then the second half. Example in this clip:
As you can see the second half doesnt work and i get no errors. If you can help me fix this, i would appreciate it. The script will be in a different reply. Thank you for helping.
2 Likes
dav2777
(dav2777)
September 10, 2023, 3:46pm
#2
This script is the game handler, in server script service
local StadiumManager = require(game.ServerScriptService.StadiumManager)
local PlayerManager = require(game.ServerScriptService.PlayerManager)
local timevalue = game.ReplicatedStorage.Events.Time
local firsthalfinprogress = game.ReplicatedStorage.Events.FirstHalfInProgress
local secondhalfinprogress = game.ReplicatedStorage.Events.SecondHalfInProgress
local breaktimeinprogress = game.ReplicatedStorage.Events.BreakInProgress
local intermissioninprogress = game.ReplicatedStorage.Events.IntermissionInProgress
local stadiumloadinprogress = game.ReplicatedStorage.Events.StadiumLoadInProgress
local secondhalfstartinprogress = game.ReplicatedStorage.Events.SecondHalfStartInProgress
--local EndOfGame = game.ReplicatedStorage.Events.EndOfGame
local lobbypart = workspace.Lobby
local gamepart = workspace.Game
local breaktimepart = workspace.BreakTime
local intermissiontime = 25 --Change this to your intermission time in seconds
local FirstHalfTime = 10 --300
local SecondHalfTime = 10 --300
local BreakTime = 10 --240
local StadiumLoadTime = 10
local SecondHalfStartTimer = 10
--local EndTime = 30
while true do
------- INTERMISSION
timevalue.Value = intermissiontime
firsthalfinprogress.Value = false
stadiumloadinprogress.Value = false
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- LOADING STADIUM
StadiumManager.LoadStadium() -- LOAD STADIUM
PlayerManager.ChooseTeams() -- CHOOSE TEAMS
PlayerManager.TpPlrStadium()
intermissioninprogress.Value = false
stadiumloadinprogress.Value = true
timevalue.Value = StadiumLoadTime
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- FIRST HALF
stadiumloadinprogress.Value = false
firsthalfinprogress.Value = true
timevalue.Value = FirstHalfTime
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- BREAK TIME
PlayerManager.TpPlrBreakTime()
breaktimeinprogress.Value = true
firsthalfinprogress.Value = false
timevalue.Value = BreakTime
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------ SECOND HALF START TIMER
PlayerManager.TpPlrStadium2()
breaktimeinprogress.Value = false
secondhalfstartinprogress.Value = true
timevalue.Value = SecondHalfStartTimer
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- SECOND HALF
secondhalfstartinprogress.Value = false
secondhalfinprogress = true
timevalue.Value = SecondHalfTime
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- End
end
3 Likes
dav2777
(dav2777)
September 10, 2023, 3:47pm
#3
This is the script that goes in the gui
wait()
if game.ReplicatedStorage.Events.IntermissionInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "INTERMISSION"
elseif game.ReplicatedStorage.Events.StadiumLoadInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "LOADING STADIUM"
elseif game.ReplicatedStorage.Events.FirstHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "FIRST HALF"
elseif game.ReplicatedStorage.Events.BreakInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "BREAK TIME"
elseif game.ReplicatedStorage.Events.SecondHalfStartInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF STARTING"
elseif game.ReplicatedStorage.Events.SecondHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF"
elseif game.ReplicatedStorage.Events.EndOfGame.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "END OF GAME"
end
game.ReplicatedStorage.Events.Time:GetPropertyChangedSignal("Value"):Connect(function()
if game.ReplicatedStorage.Events.IntermissionInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "INTERMISSION"
elseif game.ReplicatedStorage.Events.StadiumLoadInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "LOADING STADIUM"
elseif game.ReplicatedStorage.Events.FirstHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "FIRST HALF"
elseif game.ReplicatedStorage.Events.BreakInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "BREAK TIME"
elseif game.ReplicatedStorage.Events.SecondHalfStartInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF STARTING"
elseif game.ReplicatedStorage.Events.SecondHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF"
elseif game.ReplicatedStorage.Events.EndOfGame.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "END OF GAME"
end
end)
2 Likes
mc7oof
(oof)
September 10, 2023, 3:57pm
#4
Try adding some print commands to see how fat the script is getting:
local StadiumManager = require(game.ServerScriptService.StadiumManager)
local PlayerManager = require(game.ServerScriptService.PlayerManager)
local timevalue = game.ReplicatedStorage.Events.Time
local firsthalfinprogress = game.ReplicatedStorage.Events.FirstHalfInProgress
local secondhalfinprogress = game.ReplicatedStorage.Events.SecondHalfInProgress
local breaktimeinprogress = game.ReplicatedStorage.Events.BreakInProgress
local intermissioninprogress = game.ReplicatedStorage.Events.IntermissionInProgress
local stadiumloadinprogress = game.ReplicatedStorage.Events.StadiumLoadInProgress
local secondhalfstartinprogress = game.ReplicatedStorage.Events.SecondHalfStartInProgress
--local EndOfGame = game.ReplicatedStorage.Events.EndOfGame
local lobbypart = workspace.Lobby
local gamepart = workspace.Game
local breaktimepart = workspace.BreakTime
local intermissiontime = 25 --Change this to your intermission time in seconds
local FirstHalfTime = 10 --300
local SecondHalfTime = 10 --300
local BreakTime = 10 --240
local StadiumLoadTime = 10
local SecondHalfStartTimer = 10
--local EndTime = 30
while true do
------- INTERMISSION
timevalue.Value = intermissiontime
firsthalfinprogress.Value = false
stadiumloadinprogress.Value = false
print("INTERMISSION")
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- LOADING STADIUM
StadiumManager.LoadStadium() -- LOAD STADIUM
PlayerManager.ChooseTeams() -- CHOOSE TEAMS
PlayerManager.TpPlrStadium()
intermissioninprogress.Value = false
stadiumloadinprogress.Value = true
timevalue.Value = StadiumLoadTime
print("LOADING STADIUM")
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- FIRST HALF
stadiumloadinprogress.Value = false
firsthalfinprogress.Value = true
timevalue.Value = FirstHalfTime
print("FIRST HALF")
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- BREAK TIME
PlayerManager.TpPlrBreakTime()
breaktimeinprogress.Value = true
firsthalfinprogress.Value = false
timevalue.Value = BreakTime
print("BREAK TIME")
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------ SECOND HALF START TIMER
PlayerManager.TpPlrStadium2()
breaktimeinprogress.Value = false
secondhalfstartinprogress.Value = true
timevalue.Value = SecondHalfStartTimer
print("SECOND HALF START TIMER")
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- SECOND HALF
secondhalfstartinprogress.Value = false
secondhalfinprogress = true
timevalue.Value = SecondHalfTime
print("SECOND HALF")
repeat timevalue.Value = timevalue.Value - 1
wait(1)
until timevalue.Value == 0
------- End
end
3 Likes
dav2777
(dav2777)
September 10, 2023, 4:04pm
#5
I tried it and it works even during the second half, its just the script in the gui thats not working then.
1 Like
mc7oof
(oof)
September 10, 2023, 4:04pm
#6
Do the same there, use print statements to see where it is breaking.
2 Likes
dav2777
(dav2777)
September 10, 2023, 4:13pm
#7
I changed it now, i noticed that after the second half start, the gui display End of game, instead of second half. And it display the second half time (10 seconds) and not the end of game time (25 seconds). So its like if the text on the gui cant be isplaying Second half.
wait()
if game.ReplicatedStorage.Events.IntermissionInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "INTERMISSION"
print("Intermission")
elseif game.ReplicatedStorage.Events.StadiumLoadInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "LOADING STADIUM"
elseif game.ReplicatedStorage.Events.FirstHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "FIRST HALF"
elseif game.ReplicatedStorage.Events.BreakInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "BREAK TIME"
elseif game.ReplicatedStorage.Events.SecondHalfStartInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF STARTING"
elseif game.ReplicatedStorage.Events.SecondHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF"
else --game.ReplicatedStorage.Events.EndOfGame.Value == true
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "END OF GAME"
end
game.ReplicatedStorage.Events.Time:GetPropertyChangedSignal("Value"):Connect(function()
if game.ReplicatedStorage.Events.IntermissionInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "INTERMISSION"
elseif game.ReplicatedStorage.Events.StadiumLoadInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "LOADING STADIUM"
elseif game.ReplicatedStorage.Events.FirstHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "FIRST HALF"
elseif game.ReplicatedStorage.Events.BreakInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "BREAK TIME"
elseif game.ReplicatedStorage.Events.SecondHalfStartInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF STARTING"
elseif game.ReplicatedStorage.Events.SecondHalfInProgress.Value == true then
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "SECOND HALF"
else --game.ReplicatedStorage.Events.EndOfGame.Value == true
script.Parent.Text = game.ReplicatedStorage.Events.Time.Value
script.Parent.TimerText.Text = "END OF GAME"
end
end)
dav2777
(dav2777)
September 10, 2023, 8:29pm
#8
Its like if this part does not want to work
1 Like
Katrist
(Katrist)
September 10, 2023, 8:45pm
#9
The problem is that you’re setting secondhalfinprogress = true and not secondhalfinprogress.Value = true.
Game Handler:
--//Services
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Modules
local StadiumManager = require(ServerScriptService.StadiumManager)
local PlayerManager = require(ServerScriptService.PlayerManager)
--//Variables
local timevalue = ReplicatedStorage.Events.Time
local firsthalfinprogress = ReplicatedStorage.Events.FirstHalfInProgress
local secondhalfinprogress = ReplicatedStorage.Events.SecondHalfInProgress
local breaktimeinprogress = ReplicatedStorage.Events.BreakInProgress
local intermissioninprogress = ReplicatedStorage.Events.IntermissionInProgress
local stadiumloadinprogress = ReplicatedStorage.Events.StadiumLoadInProgress
local secondhalfstartinprogress = ReplicatedStorage.Events.SecondHalfStartInProgress
--local EndOfGame = ReplicatedStorage.Events.EndOfGame
local lobbypart = workspace.Lobby
local gamepart = workspace.Game
local breaktimepart = workspace.BreakTime
--//Controls
local intermissiontime = 25 --Change this to your intermission time in seconds
local FirstHalfTime = 10 --300
local SecondHalfTime = 10 --300
local BreakTime = 10 --240
local StadiumLoadTime = 10
local SecondHalfStartTimer = 10
--local EndTime = 30
--//Functions
task.spawn(function()
while true do
while timevalue.Value > 0 do
task.wait(1)
timevalue.Value -= 1
end
timevalue.Changed:Wait()
end
end)
while true do
------- INTERMISSION
timevalue.Value = intermissiontime
firsthalfinprogress.Value = false
stadiumloadinprogress.Value = false
task.wait(timevalue.Value)
------- LOADING STADIUM
StadiumManager.LoadStadium() -- LOAD STADIUM
PlayerManager.ChooseTeams() -- CHOOSE TEAMS
PlayerManager.TpPlrStadium()
intermissioninprogress.Value = false
stadiumloadinprogress.Value = true
timevalue.Value = StadiumLoadTime
task.wait(timevalue.Value)
------- FIRST HALF
stadiumloadinprogress.Value = false
firsthalfinprogress.Value = true
timevalue.Value = FirstHalfTime
task.wait(timevalue.Value)
------- BREAK TIME
PlayerManager.TpPlrBreakTime()
breaktimeinprogress.Value = true
firsthalfinprogress.Value = false
timevalue.Value = BreakTime
task.wait(timevalue.Value)
------ SECOND HALF START TIMER
PlayerManager.TpPlrStadium2()
breaktimeinprogress.Value = false
secondhalfstartinprogress.Value = true
timevalue.Value = SecondHalfStartTimer
task.wait(timevalue.Value)
------- SECOND HALF
secondhalfstartinprogress.Value = false
secondhalfinprogress.Value = true
timevalue.Value = SecondHalfTime
task.wait(timevalue.Value)
------- End
end
GUI Code:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local Events = ReplicatedStorage:WaitForChild("Events")
local TextLabel = script.Parent
--//Tables
local gameEvents = {
[Events.IntermissionInProgress] = "INTERMISSION",
[Events.StadiumLoadInProgress] = "LOADING STADIUM",
[Events.FirstHalfInProgress] = "FIRST HALF",
[Events.BreakInProgress] = "BREAK TIME",
[Events.SecondHalfStartInProgress] = "SECOND HALF STARTING",
[Events.SecondHalfInProgress] = "SECOND HALF",
[Events.EndOfGame] = "END OF GAME"
}
--//Functions
Events.Time.Changed:Connect(function(newTime)
TextLabel.Text = newTime
for statusValue, statusText in gameEvents do
if statusValue.Value then
TextLabel.TimerText.Text = statusText
return
end
end
end)
I have heavily optimized both scripts.
dav2777
(dav2777)
September 10, 2023, 8:59pm
#10
Katrist:
ed b
Thanks for the script, but there seems to still be a problem with the gui. After the Second half Starting, the game events dont change its just the timer that working well. Is there maybe a problem with the events in rep storage?
Katrist
(Katrist)
September 10, 2023, 9:00pm
#11
Could you try your original script, but just fix this part? Just want to make sure it’s a bug with the original code too, and not just mine.
1 Like
dav2777
(dav2777)
September 10, 2023, 9:03pm
#12
Katrist:
secondhalfinprogress
ok i will try it, ill let you know if it works
dav2777
(dav2777)
September 10, 2023, 9:08pm
#13
Still doesnt work, but it noticed something, for a split second second half appears then it just goes back to second half starting. And also the gui bugs now a bit
Katrist
(Katrist)
September 10, 2023, 9:10pm
#14
Try using your original GUI script too if you weren’t.
1 Like
dav2777
(dav2777)
September 10, 2023, 9:11pm
#15
Nvm it was happening because i was chaning tabs, but still the second half appears for a split second then it goes back to second half starting, but timer works well.
Katrist
(Katrist)
September 10, 2023, 9:15pm
#16
In this video, you’re still using my script. Could you try using your original one with the aforementioned changes?
dav2777
(dav2777)
September 10, 2023, 9:16pm
#17
Yes i was the script you made and told me to use
Katrist
(Katrist)
September 10, 2023, 9:16pm
#18
I told you to use your original script.
dav2777
(dav2777)
September 10, 2023, 9:17pm
#19
You talking about the original ui script or game handler
Katrist
(Katrist)
September 10, 2023, 9:17pm
#20
Can you just send your place file?