Hello! I’ve been trying to recreate a bad version of Roblox, Everything is fine, I almost finish the project and this one bug is driving me crazy, and the bad part is that I don’t even see the problem.
The problematic script is this
Entire script
local GameId = game.PlaceId
script.Parent.WorkspaceBuildings.Parent = workspace
script.Parent.ServerData.Parent = game:GetService("ServerScriptService")
script.Parent.GameStorage.Parent = game:GetService("ReplicatedStorage")
script.Parent.GameStorage.Parent = game:GetService("ServerStorage")
script.Parent.GameStorage.Parent = game:GetService("StarterGui")
local DS = game:GetService("DataStoreService")
local HTTPS = game:GetService("HttpService")
local GDS = DS:GetDataStore("GamesData","Testing16")
local Data = GDS:GetAsync("Data")
local GameDataGot
for _,GameData in ipairs(Data) do
GameData = HTTPS:JSONDecode(GameData)
print(GameData.PlaceId,GameId)
if tonumber(GameData.PlaceId) == tonumber(GameId) then
warn(true)
GameDataGot = GameData.Content
end
end
warn(GameDataGot)
``
Only the broken part
local DS = game:GetService("DataStoreService")
local HTTPS = game:GetService("HttpService")
local GDS = DS:GetDataStore("GamesData","Testing16")
local Data = GDS:GetAsync("Data")
local GameDataGot
for _,GameData in ipairs(Data) do
GameData = HTTPS:JSONDecode(GameData)
print(GameData.PlaceId,GameId)
if tonumber(GameData.PlaceId) == tonumber(GameId) then
warn(true)
GameDataGot = GameData.Content
end
end
warn(GameDataGot)
The saving script:
Entire Script
local DS = game:GetService("DataStoreService")
local LastUploaded = DS:GetDataStore("LastTimeUploaded")
local GamesDataStore = DS:GetDataStore("GamesData","Testing16")
local HTTPService = game:GetService("HttpService")
local TextService = game:GetService("TextService")
local AS = game:GetService("AssetService")
local function Filter(text,Plr)
local Result = TextService:FilterStringAsync(text,Plr,Enum.TextFilterContext.PublicChat)
return Result:GetNonChatStringForBroadcastAsync()
end
local StartData = {
[1] = {
{
[1] = "Baseplate";
[2] = "Part";
[3] = "Dark stone grey";
[4] = true;
[5] = "Plastic";
[6] = 0;
[7] = 0;
[8] = {0,10,0};
[9] = {0,0,0};
[10] = {0,0,0};
[11] = true;
[12] = true;
[13] = true;
[14] = 0;
[15] = false;
[16] = 0;
[17] = "Block";
[18] = {204, 20, 204};
};
};
[2] = {
};
[3] = {
};
[4] = {
};
[5] = {
};
[6] = {
};
[7] = {
};
}
local UseStartGame = true
local function GetStartGame()
if not UseStartGame then
local Link = "https://pastebin.com/raw/".."CP65frLE"
loadstring("Script = "..HTTPService:JSONEncode(HTTPService:GetAsync(Link,true)))()
return Script
else
return StartData
end
end
game.ReplicatedStorage.Events.GetGameData.OnServerInvoke = function()
local Data = GamesDataStore:GetAsync("Data") or {}
return Data
end
game.ReplicatedStorage.Events.CreateNewGame.OnServerEvent:Connect(function(Player,Name,Description,Id)
Name = Filter(Name,Player.UserId)
Description = Filter(Description,Player.UserId)
if typeof(Name) == "string" and typeof(Description) == "string" then
local Data = GamesDataStore:GetAsync("Data") or {}
if #Name > 24 then
Name = string.sub(Name,1,24)
end
if #Description > 200 then
Description = string.sub(Description,1,200)
end
if not tonumber(Id) then
Id = 5671030466
end
local PlaceId = AS:CreatePlaceAsync("RoScratchAlphaPlace",5996633355,"This is just an placeholder for the real game. Please join it only from RoScratch")
table.insert(Data,HTTPService:JSONEncode({
["GameName"] = Name;
["GameImage"] = "http://www.roblox.com/asset/?id="..tonumber(Id);
["GameDescription"] = Description;
["CreatorId"] = Player.UserId;
["Content"] = GetStartGame();
["GameId"] = #Data + 1;
["PlaceId"] = PlaceId
}))
GamesDataStore:SetAsync("Data",Data)
DS:GetOrderedDataStore("GameVisits4"):SetAsync(#Data + 1,0)
game.ReplicatedStorage.Events.RefreshOwnedGames:FireClient(Player)
end
end)
game.ReplicatedStorage.Events.ChangeNewGame.OnServerEvent:Connect(function(Player,Name,Description,Id,GameId)
Name = Filter(Name,Player.UserId)
Description = Filter(Description,Player.UserId)
if typeof(Name) == "string" and typeof(Description) == "string" then
local Data = GamesDataStore:GetAsync("Data")
if #Name > 24 then
Name = string.sub(Name,1,24)
end
if #Description > 200 then
Description = string.sub(Description,1,200)
end
if not tonumber(Id) then
Id = 5671030466
end
local FoundData,Number = nil,0
for i,DataTable in ipairs(Data) do
Number = i;
DataTable = HTTPService:JSONDecode(DataTable)
if DataTable.CreatorId == Player.UserId then
if DataTable.GameId == GameId then
FoundData = DataTable
break
end
end
end
if FoundData and FoundData.GameId == GameId then
local NewData = {
["GameName"] = Name;
["GameImage"] = "http://www.roblox.com/asset/?id="..tonumber(Id);
["GameDescription"] = Description;
["CreatorId"] = Data[Number].CreatorId;
["Content"] = Data[Number].Content;
["GameId"] = Data[Number].GameId;
["PlaceId"] = Data[Number].PlaceId;
}
NewData = HTTPService:JSONEncode(NewData)
Data[Number] = NewData
GamesDataStore:SetAsync("Data",Data)
game.ReplicatedStorage.Events.RefreshOwnedGames:FireClient(Player)
end
end
end)
game.ReplicatedStorage.Events.ChangeContent.OnServerEvent:Connect(function(Player,GameId,Content)
local Data = GamesDataStore:GetAsync("Data")
local FoundData,Number = nil,0
for i,DataTable in ipairs(Data) do
DataTable = HTTPService:JSONDecode(DataTable)
Number = i;
local CreatorId,GameIdData = DataTable.CreatorId,DataTable.GameId
local Found = 0
if CreatorId == Player.UserId then
if GameId == GameIdData then
FoundData = DataTable
break
end
end
end
if FoundData and FoundData.GameId == GameId then
warn(Content)
local NewData = {
["GameName"] = FoundData.GameName;
["GameImage"] = FoundData.GameImage;
["GameDescription"] = FoundData.GameDescription;
["CreatorId"] = FoundData.CreatorId;
["Content"] = Content;
["GameId"] = FoundData.GameId;
}
NewData = HTTPService:JSONEncode(NewData)
Data[Number] = NewData
GamesDataStore:SetAsync("Data",Data)
game.ReplicatedStorage.Events.RefreshOwnedGames:FireClient(Player)
end
end)
Only the RemoteEvent
The problem is at AS:CreatePlaceAsync(“RoScratchAlphaPlace”,5996633355,“This is just an placeholder for the real game. Please join it only from RoScratch”)
game.ReplicatedStorage.Events.CreateNewGame.OnServerEvent:Connect(function(Player,Name,Description,Id)
Name = Filter(Name,Player.UserId)
Description = Filter(Description,Player.UserId)
if typeof(Name) == "string" and typeof(Description) == "string" then
local Data = GamesDataStore:GetAsync("Data") or {}
if #Name > 24 then
Name = string.sub(Name,1,24)
end
if #Description > 200 then
Description = string.sub(Description,1,200)
end
if not tonumber(Id) then
Id = 5671030466
end
local PlaceId = AS:CreatePlaceAsync("RoScratchAlphaPlace",5996633355,"This is just an placeholder for the real game. Please join it only from RoScratch")
table.insert(Data,HTTPService:JSONEncode({
["GameName"] = Name;
["GameImage"] = "http://www.roblox.com/asset/?id="..tonumber(Id);
["GameDescription"] = Description;
["CreatorId"] = Player.UserId;
["Content"] = GetStartGame();
["GameId"] = #Data + 1;
["PlaceId"] = PlaceId
}))
GamesDataStore:SetAsync("Data",Data)
DS:GetOrderedDataStore("GameVisits4"):SetAsync(#Data + 1,0)
game.ReplicatedStorage.Events.RefreshOwnedGames:FireClient(Player)
end
end)