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 :)

1 comment
That if statement runs one time and one time only, if you want it to endlessly check if the Value is not 0 then you need a loop