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?

18 comments

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.

0

even booga booga uses them

0

Because they don't know how to make a game, or they made them LOOK like messages. And they are deprecated.

0

well i'll do that later , it drops no errors anyway

0

It doesn't matter if it doesn't, you should not be using deprecated methods, neither should you use global variables.

0

why i shouldn't be using global variables

0

Because they are bad practice. They make code messy (as shown), pollute the global namespace and can increase the risk for name collisions.

0

i didn't put global variables tho

0

Yes you did. Your functions are global. It's a global variable.

0

But i wont do any functions that have the same name..

0

You shouldn't be using globales at all. There's no excuse to use them. I'm just giving you better practices.

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

0

what?

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

0

and if you use a global and its not in any script block than it's okay lol

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

0

yes i did