I have a problem where one of my datastore scripts go on a loop. It repeatedly saves.
I have print() to show up when it saves, and it shows in the output. But it goes over and over infinitely. None of my other datastore scripts do this, and they're the same scripts just saving different values. Here's the one that's looping:
local DataStore = game:GetService("DataStoreService") local ds1 = DataStore:GetDataStore("leveldatasaveforedgame") game.Players.PlayerAdded:connect(function(player) local Level = Instance.new("IntValue",player) Level.Name = "Level" Level.Value = ds1:GetAsync(player.UserId) or 0 ds1:SetAsync(player.UserId, Level .Value) Level.Changed:connect(function() print("Level Process Begin") ds1:SetAsync(player.UserId, Level.Value) print(player.Name .. " has had " .. Level.Value .. " saved as Level User ID is " .. player.UserId) end) end) game.Players.PlayerRemoving:connect(function(player) ds1:SetAsync(player.UserId, player.Level.Value) print(player.Name .. "has left. Saved" .. player.Level.Value .. "as Level") end)
How do I stop it from looping?