Datastore Problem

Basically what I am trying to do is it loads a datastore that counts down for every robux purchase. This works perfectly in studio but does not work in the actual game.
My Code:

local mydatasore = datastoreservice:GetDataStore("myDataStore")

game.Players.PlayerAdded:Connect(function(player)
	local data
	local sucess, errormessage = pcall(function()
		data = mydatasore:GetAsync("Calagoz".."-robux")
		end)
			player.PlayerGui.ScreenGui.info.Text = "ROBUX left until we Re-Open: " .. tonumber(data)
			player.PlayerGui.ScreenGui.info.Value.Value = tonumber(data)
if sucess == false then
error(errormessage)
		end
		

	
	end)

I can’t find your problem but I have tips.
First, add if success then around those 2 lines which show the Robux amount like this:

local mydatasore = datastoreservice:GetDataStore("myDataStore")

game.Players.PlayerAdded:Connect(function(player)
	local data
	local sucess, errormessage = pcall(function()
		data = mydatasore:GetAsync("Calagoz".."-robux")
	end)
	
	if success then
		player.PlayerGui.ScreenGui.info.Text = "ROBUX left until we Re-Open: " .. tonumber(data)
		player.PlayerGui.ScreenGui.info.Value.Value = tonumber(data)
	else
		error(errormessage)
	end
end)

Why? If the datastore call errors for some reason, you aren’t trying to set the text.

Second, I wouldn’t set player gui text from the server, only client and use a remote event for that. So instead of setting the text on the server, fire a remote event which sets that text on the client.

Also, why are you converting the data into number if you want to concatenate it with a string?

Those are the only problems I could spot in that code.

1 Like

This did not fix the problem. You can have a look at the game here: GroupRanker Funding - Roblox