This plugin will fix the problem where Game images won’t load in local test servers.
This issue has been referenced at least three times in the past few days:
- Image assets not loading when testing on a local server
- Game assets stopped loading in local server clients
- All image assets in studio failing to load in server test mode
How it works
Problem:
- Game assets won’t load because the
GameId
is0
- The
GameId
is only0
for the clients, not the server. - The
GameId
isn’t replicating to test clients for some reason
Solution:
- Manually replicate the
GameId
with a Value object - Set the
GameId
by script.
Source
while not game:FindService("NetworkServer") and not game:FindService("NetworkClient") do
game.ChildAdded:wait()
end
local placeDataValue
if game:FindService("NetworkServer") then
placeDataValue = game:GetService("ReplicatedFirst"):FindFirstChild("PlaceData")
if placeDataValue then
placeDataValue:Destroy()
end
placeDataValue = Instance.new("StringValue")
placeDataValue.Name = "PlaceData"
placeDataValue.Value = game:GetService("HttpService"):JSONEncode({
UniverseId = game.GameId,
PlaceId = game.PlaceId
})
placeDataValue.Parent = game:GetService("ReplicatedFirst")
elseif game:FindService("NetworkClient") then
placeDataValue = game:GetService("ReplicatedFirst"):WaitForChild("PlaceData", math.huge)
local placeData = game:GetService("HttpService"):JSONDecode(placeDataValue.Value)
game:SetUniverseId(placeData.UniverseId)
game:SetPlaceId(placeData.PlaceId)
end