Hello, Developers! I am currently working on a Football (Soccer) game and In my game there are periods where there is training and actual the actual game. But in my main game loop the Value for in game is not changing. Here are the two scripts that change In game value.
----Main Game Loop—
RedGoal = game.Workspace.DetectR
Ball = game.Workspace.Ball
Centre = game.Workspace.Part
game.Players.PlayerAdded:Connect(function(player)
game.ReplicatedStorage.inGame.Changed:Connect(function()
if game.ReplicatedStorage.inGame.Value == true then
wait(0.35)
if game.ReplicatedStorage.inGame.Value == true then
BlueGoal.Touched:Connect(function(hit)
if hit.Name == "Ball" then
player.PlayerGui.Scored.Frame.Visible = true
PlayerName = game.ReplicatedStorage.Value.Value
player.PlayerGui.Scored.Frame.TextLabel.Text = PlayerName .. " has scored!"
for _, Players in pairs(game.Players:GetChildren())do
Players:LoadCharacter()
Players.Character.HumanoidRootPart.Anchored = true
end
Ball.CFrame = Centre.CFrame
Ball.Anchored = true
wait(3)
player.PlayerGui.Scored.Frame.Visible = false
Ball.Anchored = false
game.ReplicatedStorage.ScoreRed.Value += game.ReplicatedStorage.ScoreRed.Value
player.PlayerGui.Seconds.Sec.Text = game.ReplicatedStorage.ScoreBlue.Value .. " - " .. game.ReplicatedStorage.ScoreRed.Value
player.PlayerGui.Seconds.Sec.Visible = true
wait(1)
player.PlayerGui.Seconds.Sec.Visible = false
end
end)
RedGoal.Touched:Connect(function(hit)
if hit.Name == "Ball" then
player.PlayerGui.Scored.Frame.Visible = true
PlayerName = game.ReplicatedStorage.Value.Value
player.PlayerGui.Scored.Frame.TextLabel.Text = PlayerName .. " has scored!"
for _, Players in pairs(game.Players:GetChildren())do
Players:LoadCharacter()
Players.Character.HumanoidRootPart.Anchored = true
end
Ball.CFrame = Centre.CFrame
Ball.Anchored = true
wait(3)
player.PlayerGui.Scored.Frame.Visible = false
Ball.Anchored = false
game.ReplicatedStorage.ScoreBlue.Value += game.ReplicatedStorage.ScoreBlue.Value
player.PlayerGui.Seconds.Sec.Text = game.ReplicatedStorage.ScoreBlue.Value .. " - " .. game.ReplicatedStorage.ScoreRed.Value
player.PlayerGui.Seconds.Sec.Visible = true
wait(1)
player.PlayerGui.Seconds.Sec.Visible = false
end
end)
end
end
end)
game.ReplicatedStorage.inGame.Changed:Connect(function()
if game.ReplicatedStorage.inGame.Value == false then
print("Training time")
Ball.Parent = game.Lighting
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
game.ReplicatedStorage.CleanUp.Changed:Connect(function()
if game.ReplicatedStorage.CleanUp.Value == true then
for i,v in pairs(game.Workspace:GetChildren())do
if v.Name == "Ball" then
v:Remove()
end
end
end
end)
Ball.Parent = workspace
Ball.CFrame = game.Workspace.Part.CFrame
end
end)
if game.ReplicatedStorage.inGame.Value == false then
print("Training time")
Ball.Parent = game.Lighting
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
TrainBall = Ball:Clone()
TrainBall.Parent = game.Workspace
game.ReplicatedStorage.CleanUp.Changed:Connect(function()
if game.ReplicatedStorage.CleanUp.Value == true then
for i,v in pairs(game.Workspace:GetChildren())do
if v.Name == "Ball" then
v:Remove()
end
end
end
end)
Ball.Parent = workspace
Ball.CFrame = game.Workspace.Part.CFrame
end
end)
—Timer Script (Server) —
local players = game:GetService("Players")
local minutesvalue = rep:WaitForChild("Minutes")
local secondsvalue = rep:WaitForChild("Seconds")
if game.ReplicatedStorage.inGame.Value == false then
game.ReplicatedStorage.ModeValue.Value = "Training"
minutesvalue.Value = 0
secondsvalue.Value = 60
repeat
if secondsvalue.Value <= 0 then
minutesvalue.Value = minutesvalue.Value - 1
secondsvalue.Value = 59
else
secondsvalue.Value = secondsvalue.Value - 1
end
wait(1)
until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
game.ReplicatedStorage.CleanUp.Value = true
wait(1.5)
game.ReplicatedStorage.CleanUp.Value = false
end
game.ReplicatedStorage.inGame.Value = true
print("true")
game.ReplicatedStorage.inGame.Changed:Connect(function()
if game.ReplicatedStorage.inGame.Value == false then
game.ReplicatedStorage.ModeValue.Value = "Training"
minutesvalue.Value = 0
secondsvalue.Value = 60
repeat
if secondsvalue.Value <= 0 then
minutesvalue.Value = minutesvalue.Value - 1
secondsvalue.Value = 59
else
secondsvalue.Value = secondsvalue.Value - 1
end
wait(1)
until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
game.ReplicatedStorage.CleanUp.Value = true
wait(1.5)
game.ReplicatedStorage.CleanUp.Value = false
end
end)
game.ReplicatedStorage.inGame.Value = true
print("true")
game.ReplicatedStorage.inGame.Changed:Connect(function()
if game.ReplicatedStorage.inGame.Value == true then
game.ReplicatedStorage.ModeValue.Value = "Game"
minutesvalue.Value = 5
secondsvalue.Value = 0
repeat
if secondsvalue.Value <= 0 then
minutesvalue.Value = minutesvalue.Value - 1
secondsvalue.Value = 59
else
secondsvalue.Value = secondsvalue.Value - 1
end
wait(1)
print(minutesvalue.value , ":", secondsvalue.value)
until secondsvalue.Value <= 0 and minutesvalue.Value <= 0
end
end)
game.ReplicatedStorage.inGame.Value = false
print("false")
Help will be greatly appreciated. And also there are no errors in the output that are related to any of this.