Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Repeat wait seems to not be working, Can you let me know why?

Asked by
DBoi941 57
5 years ago

Here is what I have in a Script in ServerScriptService.

    local currentVer = game.Workspace.PlaceVersion.Value

local getPlaceVer = game.PlaceVersion

local stats1 = game.workspace.ServerStats.GameVersion.SurfaceGui.Stat

local stats2 = game.workspace.ServerStats.GameVersion.SurfaceGui.StatDrop

print(getPlaceVer, "Script Ran")



while true do

repeat wait() until currentVer ~= getPlaceVer

local getPlaceVer = game.PlaceVersion

print(getPlaceVer)

stats1.Text = "Outdated"

stats1.TextColor3 = Color3.new(255, 0, 0)

stats2.Text = "Outdated"

break

end
2
Explain better. Console errors, what's it supposed to do, etc. Aimarekin 345 — 5y
0
No errors in console. I am checking the game version and if it is not the same as the current game to change a gui textbox text value. DBoi941 57 — 5y
0
Its to show players in game that the server is old. DBoi941 57 — 5y
0
I see the problem now the (game.PlaceVersion) is pulling from the game not Version history on Roblox. Now how would I get the Version history from Roblox? I am reading this: https://developer.roblox.com/api-reference/property/DataModel/PlaceVersion DBoi941 57 — 5y
0
But if the place is outdated it will automatically disconnect everyone Luka_Gaming07 534 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Please read on how game.PlaceVersion works. It says in the roblox official wiki that this variable is not updated, and only shows the place version that the server is currently on, in this case, it returns the exact same value as currentVer. You need to save the new version in a data store, and have every server check its version against the datastore version, and if their version is greater, then set the datastore version to that server's version, doing this will allow servers to then check their version against the datastored version to see if their version is less then, if so, then you change the text. Heres a dummy script, which you will need to change to suit your needs.

local datastore= game:GetService("DatastoreService"):GetDatastore("GameVer")
local key= "serverversion"
local placeVer= datastore:GetAsync(key)
local currentVer= game.PlaceVersion
if placeVer then
    if placeVer<=game.PlaceVersion then
        datastore:SetAsync(key,game.PlaceVersion)
        currentVer= game.PlaceVersion
    end
else
    datastore:SetAsync(key,game.PlaceVersion)
end
--We have to wait 6+ secs so that we can make sure the datastore wont error. (I have a module that can be used to sort of make this easier, link below code block).
--Also not really recommended you do a while wait in a while wait, but you can modify this to your liking.
while wait() do
    while wait(6) do
        placeVer= datastore:GetAsync(key)
        if not placeVer then
            break
        end
        repeat wait() until placeVer>currentVer
        --Rest of your code.
    end
end

If you want my module to make datastore setting, getting and saving a little easier(also has a neat function to save almost all value objects), then click here.

0
Thank you very much. You have explained it very well, And I do understand now. I wish I could upvote but I cant yet. DBoi941 57 — 5y
0
Not a problem, hopefully your game comes out great! popgoesme700 113 — 5y
Ad

Answer this question