You can write your topic however you want, but you need to answer these questions:
-
I am trying to use the global ‘game’ but it does not work for whatever reason
-
For some reason it errors: “ServerScriptService.MainScript:18: attempt to index nil with ‘Game’”
-
I tested the game on roblox itself and roblox studio and both have the same issue
This is not the StarterPlace, the following code is part of a Server Script called ‘MainScript’ inside of ServerScriptService:
local RS = game:GetService("ReplicatedStorage")
local DSS = game:GetService("DataStoreService")
local httpService = game:GetService("HttpService")
local players = game:GetService("Players")
local provinceDataStore = DSS:GetDataStore("ProvinceDS"..209)
local provinceInfo = RS:WaitForChild("provinceInfo")
local function loadData()
local provinceName = game.Name
local provinceData
local success, errorMessage = pcall(function()
provinceData = httpService:JSONDecode(provinceDataStore:GetAsync("Info"))
end)
provinceInfo:WaitForChild("Owner").Value = provinceData[provinceName]["Owner"]
provinceInfo:WaitForChild("Attacker").Value = provinceData[provinceName]["Attacker"]
end
loadData()
The line which errors is:
provinceInfo:WaitForChild("Owner").Value = provinceData[provinceName]["Owner"]