So I have a script that checks to see if the game is updated then warns players and kicks everyone. The problem is that EVERY time I join (In studio, IDK about in game), it says that the game was updated. My script:
local DSS = game:GetService("DataStoreService") local lastUpdated = DSS:GetDataStore("LastUpdated") local function CheckForUpdate() if game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Updated ~= lastUpdated:GetAsync("LastUpdated") then lastUpdated:SetAsync(game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Updated) status.Value = "The game has been updated!" for i = 10, 0, -1 do seconds.Value = i wait(1) end for i, player in pairs(game.Players:GetPlayers()) do player:Kick("The game has been updated! Please wait a minute, then join a new server.") end end end
EDIT: It gives me an error on line 6: Argument 2 missing or nil.
Not sure about that one, but I created a different version that works. I've tested in live servers.
local previousVersion = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Updated --// This will get the first version of the game when it starts open game.Players.PlayerAdded:Connect(function(player) --// Starts running when a player joins. while wait(1) do --// Will always loop through the check, every 1 second. (Reduces memory use) local newVersion = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Updated --// Always checks for an updated version if newVersion ~= previousVersion then --// Checks if the game has been updated for _,player in pairs(game:GetService("Players"):GetChildren()) do player:Kick(game.Name.." Has Been Updated!") --// Kicks all the players telling them the game has been updated! end end end end)
In my opinion, I don't think you need DataStore for game updates. You just need the first version of the current server when it first opens, and then do a loop checking if the game has been updated.
Hope this helped! If this is what you're looking for, let me know by selecting this as an answer!
I recommend using killerbrenden's script, but here's why your script isn't working:
if
to take care of whether to update the data store or not, and then you'd have a loop to see if any other server has updated the data store since you last checked it. If so, then the version has changed.