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
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Sorts game wins or losses local BlueTeamPoints = ReplicatedStorage:WaitForChild("BlueTeamPoints") local RedTeamPoints = ReplicatedStorage:WaitForChild("RedTeamPoints") if BlueTeamPoints.Value == 0 then print("Blue Team Lost") for _, Player in pairs(game.Players:GetChildren()) do if Player.Team.Name == "Really Blue" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 100 elseif Player.Team.Name == "Really Red" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 300 end end elseif RedTeamPoints.Value == 0 then print("Red Team Lost") for _, Player in pairs(game.Players:GetChildren()) do if Player.Team.Name == "Really Red" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 100 elseif Player.Team.Name == "Really Blue" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 300 end end end
It doesnt run at all even when the IntValue is = 0
Does anyone have any ideas? Thank you for your time :)
Well, you forgot to have a repeat
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Sorts game wins or losses local BlueTeamPoints = ReplicatedStorage:WaitForChild("BlueTeamPoints") local RedTeamPoints = ReplicatedStorage:WaitForChild("RedTeamPoints") local loop = true while loop do -- Added a loop if BlueTeamPoints.Value == 0 then loop = false -- Changes the loop to false which would stop the loop. Same with other print("Blue Team Lost") for _, Player in pairs(game.Players:GetChildren()) do if Player.Team.Name == "Really Blue" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 100 elseif Player.Team.Name == "Really Red" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 300 end end elseif RedTeamPoints.Value == 0 then loop = false print("Red Team Lost") for _, Player in pairs(game.Players:GetChildren()) do if Player.Team.Name == "Really Red" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Losses").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 100 elseif Player.Team.Name == "Really Blue" then ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Wins").Value + 1 ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value = ReplicatedStorage.DataFile[Player.Name]:WaitForChild("Crystals").Value + 300 end end end end