Script isnt running when IntValue reaches 0?
I have a script and its supposed to fire when an IntValue = 0.
Its a script inside ServerScriptService and the IntValue is inside ReplicatedStorage.
Heres the code
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
04 | local BlueTeamPoints = ReplicatedStorage:WaitForChild( "BlueTeamPoints" ) |
05 | local RedTeamPoints = ReplicatedStorage:WaitForChild( "RedTeamPoints" ) |
07 | if BlueTeamPoints.Value = = 0 then |
08 | print ( "Blue Team Lost" ) |
09 | for _, Player in pairs (game.Players:GetChildren()) do |
10 | if Player.Team.Name = = "Really Blue" then |
11 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Losses" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Losses" ).Value + 1 |
12 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value + 100 |
13 | elseif Player.Team.Name = = "Really Red" then |
14 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Wins" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Wins" ).Value + 1 |
15 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value + 300 |
18 | elseif RedTeamPoints.Value = = 0 then |
19 | print ( "Red Team Lost" ) |
20 | for _, Player in pairs (game.Players:GetChildren()) do |
21 | if Player.Team.Name = = "Really Red" then |
22 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Losses" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Losses" ).Value + 1 |
23 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value + 100 |
24 | elseif Player.Team.Name = = "Really Blue" then |
25 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Wins" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Wins" ).Value + 1 |
26 | ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value = ReplicatedStorage.DataFile [ Player.Name ] :WaitForChild( "Crystals" ).Value + 300 |
It doesnt run at all even when the IntValue is = 0
Does anyone have any ideas? Thank you for your time :)