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
local connection
function MessageToScreen(msg,isperm,waitt)
local a = Instance.new("Message")
a.Name = "ys27h872hs3gd7agd726ds8agwd972gdsga78wgd27d3"
a.Parent = workspace
a.Text = msg
if isperm == false then
wait(waitt)
a:remove()
end
end
function UpdateServers(key)
print("Starting..")
MessageToScreen("Servers Are Updating , Please wait...",true,math.huge)
print("Teleporting")
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
game:GetService("TeleportService"):Teleport(838000617,v)
end
end
connection = startUpdate:OnUpdate("UPDTSRVS",UpdateServers)
I found out that this works , but when i join the game the connection runs , and i did not even change any value in DataStore.. Please help

5 comments
Would be nice if there were any comments on there to indicate what is happening, what it's calling and what it's using. Basically telling what everything is supposed to do.
ok , When i join a game i made , there's a gui , a localscript sends a message through a remoteEvent , the server script catches it and then it changes a value in a dataStore, while in the other game when it catches a new update in a key it runs the function UpdateServers() as callback, then in that function the script would make a message and would teleport everyone to a game , but the problem is
that the code is running everytime you join the game , and the key does not change , that's my problem
Messages are deprecated, and don't use global variables for functions. Always use local.
but that won't help because that can be changed, global and local functions do not make sense , even if i use same name with a global or local function it still will be confused