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

Im trying to do a updateServers script , and it doesn't works , why?(oml 2 hours and no answers)

Asked by 5 years ago
Edited 5 years ago

Hello , i have been creating a script builder , i made two places one for waiting and another to give the info that the servers will update... The problem i have is that when i try to give the request it doesn't work

Code of the request of updates

-- RemoteEvent will be called by a localscript
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
    print("Received request.")
    local data = game:GetService("DataStoreService")
    local startUpdate = data:GetDataStore("CENSORED")
    startUpdate:UpdateAsync("UPDTSRVS",function(old)
        local newValue = old
        newValue = newValue+1
        return newValue
    end)
end)

Code of the script that will action on update

function MessageToScreen(msg,isperm,waitt)
    local a = Instance.new("Message")
    a.Name = "ys27h872hs3gd7agd726ds8agwd972gdsga78wgd27d3"
    a.Text = msg
    if isperm == false then
        wait(waitt)
        a:remove()
    end
end
function UpdateServers(key)
    print("New server update , New update ID is: "..key)
    print("Starting..")
    MessageToScreen("Servers Are Updating , Please wait...",true,math.huge)
    for i,v in pairs(game:GetService("Players"):GetPlayers()) do
        game:GetService("TeleportService"):Teleport(838000617,v)
    end
end
startUpdate:OnUpdate("UPDTSRVS",UpdateServers)

Why didn't it work?

0
:remove is deprecated, use :Destroy. Messages are also deprecated, use Guis, a TextLabel if it should not be interacted with. Also, use local variables, you are using global for your functions. User#24403 69 — 5y
0
even booga booga uses them maumaumaumaumaumau 98 — 5y
0
Because they don't know how to make a game, or they made them LOOK like messages. And they are deprecated. User#24403 69 — 5y
0
well i'll do that later , it drops no errors anyway maumaumaumaumaumau 98 — 5y
View all comments (14 more)
0
It doesn't matter if it doesn't, you should not be using deprecated methods, neither should you use global variables. User#24403 69 — 5y
0
why i shouldn't be using global variables maumaumaumaumaumau 98 — 5y
0
Because they are bad practice. They make code messy (as shown), pollute the global namespace and can increase the risk for name collisions. User#24403 69 — 5y
0
i didn't put global variables tho maumaumaumaumaumau 98 — 5y
0
Yes you did. Your functions are global. It's a global variable. User#24403 69 — 5y
0
But i wont do any functions that have the same name.. maumaumaumaumaumau 98 — 5y
0
You shouldn't be using globales at all. There's no excuse to use them. I'm just giving you better practices. User#24403 69 — 5y
0
when i put a local function i have to write the entire name , when i use globals i just put the beggining and it will auto-write maumaumaumaumaumau 98 — 5y
0
what? User#24403 69 — 5y
0
it's weird that deprecated things work, so it's not the end of the world if you accidentally use :remove() instead of :Destroy(), but just keep them up to date in case for example roblox crates an update that all deprecated things dont work anymore at all mudathir2007 157 — 5y
0
and if you use a global and its not in any script block than it's okay lol mudathir2007 157 — 5y
0
y'all too busy arguing over depreciated code instead of actually answering the question and it's getting kind of ridiculous. Are studio API services enabled? Have you tried running print statements all over to see if it's getting that far? Datastore functions should be wrapped in pcall as well to catch errors...there's a lot of possibilities with this script Vulkarin 581 — 5y
0
yes i did maumaumaumaumaumau 98 — 5y

Answer this question