This is the code so when the button is clicked it changes the Boolean to true and when the sell button is clicked the Boolean is changed to false but the script keeps giving money even though the Boolean is false.
game.ReplicatedStorage.RES.DS.OnServerEvent:Connect(function(player)
game.ReplicatedStorage.StockChecks.DonutCheck.Value = true
while true do
if game.ReplicatedStorage.StockChecks.DonutCheck.Value == true then
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 10
wait(5)
else
print("Stoped The Stocks")
end
end
end)
game.ReplicatedStorage.RES.CM.OnServerEvent:Connect(function(player)
game.ReplicatedStorage.StockChecks.CarCheck.Value = true
while true do
if game.ReplicatedStorage.StockChecks.CarCheck.Value == true then
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100
wait(5)
else
print("Stoped The Stocks")
end
end
end)
game.ReplicatedStorage.RES.GD.OnServerEvent:Connect(function(player)
game.ReplicatedStorage.StockChecks.GameCheck.Value = true
while true do
if game.ReplicatedStorage.StockChecks.GameCheck.Value == true then
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1000
wait(5)
else
print("Stoped The Stocks")
end
end
end)