Steaming Enabled Error, 'Persistent' isn't a Good Option

Long story short, I have collectibles in my game and I’m using StreamingEnabled. The game can only reference the collectible models if the ‘ModelStreamingMode’ is set to ‘Persistent’. The issue with this is that I will have 48 collectibles in my game constantly persisting/being loaded.


I’m using DataStores to save player data across 3 different ‘save files’. I’d like to make it so that when the player loads into a save file, the ‘golden toast’ collectibles are updated to be slightly transparent, indicating that the player has already collected that collectible.

My code ‘works’ but errors if the collectible models are not ‘Persistent’. The code for setting the collectible to semi-transparent is happening on the Client, not the server. However, the game is single-player, thus I could technically do it on the server as well, but that’s not a great solution either I think.

I also have various worlds/levels the player can go to, if I could set models to persistent on runtime based on what world the player is in, that’d be awesome. But, that doesn’t seem to be a thing.


It’s not a coding issue per-say as it all works fine when the models are ‘Persistent’, but that isn’t good for my games performance. Hope that all makes sense.

I can provide code, but it wouldn't make sense without a bunch of other stuff that would be ~2,000 lines of code. Here's this anyways though:

function updateGoldenToastCollectionUI()
	
	--print("Golden Toast Test 3")
	
	if currentSaveFilePlayerIsPlayingOn.Value == "SaveFile1" then
		local listOfWorldBasedGoldenToastCollected_Folder = game.Players.LocalPlayer:WaitForChild("playerDataFolder").saveFile1_TableFolder.collectiblesCollectedTableFolder.listOfWorldBasedGoldenToastCollected_Folder
		local worldFoldersList = listOfWorldBasedGoldenToastCollected_Folder:GetChildren()
		--print(worldFoldersList)
		for i, worldFolder in pairs(worldFoldersList) do
			local boolValues = worldFolder:GetChildren()
			--print(boolValues)
			for i, boolValue in pairs(boolValues) do
				local goldenToastUIForThisBoolValue = WorldBasedCollectiblesFrame:WaitForChild(worldFolder.Name):WaitForChild(boolValue.Name)
				local goldenToastFolderFromWorldThisCollectibleIsIn = InGame_Collectibles_Folder:WaitForChild(worldFolder.Name):WaitForChild("GoldenToast_Folder")	

				for i, goldenToastObjectModel in pairs(goldenToastFolderFromWorldThisCollectibleIsIn:GetChildren()) do

					local goldenToastObjectModelIDNumber = goldenToastObjectModel:WaitForChild("collectibleNumberOutOfTotalInSpecificWorld_NumberValue")
					local collectedStringPlusIDNumber = "Collected"..tostring(goldenToastObjectModelIDNumber.Value)

					--print(boolValue.Name,collectedStringPlusIDNumber)

					if boolValue.Name == collectedStringPlusIDNumber then

						--print("HALLO?!")

						if boolValue.Value == true then
							-- player collected this golden toast
							goldenToastUIForThisBoolValue.ImageColor3 = Color3.fromRGB(255,255,255)
							goldenToastObjectModel:WaitForChild("goldenToastMesh").Transparency = 0.35

						elseif boolValue.Value == false then
							goldenToastUIForThisBoolValue.ImageColor3 = Color3.fromRGB(0,0,0)
							goldenToastObjectModel:WaitForChild("goldenToastMesh").Transparency = 0

						end

						goldenToastObjectModel:WaitForChild("collectedBoolValue").Value = boolValue.Value

					end

				end

			end

		end
		
	elseif currentSaveFilePlayerIsPlayingOn.Value == "SaveFile2" then
		local listOfWorldBasedGoldenToastCollected_Folder = game.Players.LocalPlayer:WaitForChild("playerDataFolder").saveFile2_TableFolder.collectiblesCollectedTableFolder.listOfWorldBasedGoldenToastCollected_Folder
		local worldFoldersList = listOfWorldBasedGoldenToastCollected_Folder:GetChildren()

		for i, worldFolder in pairs(worldFoldersList) do
			local boolValues = worldFolder:GetChildren()
			--print(boolValues)
			for i, boolValue in pairs(boolValues) do
				local goldenToastUIForThisBoolValue = WorldBasedCollectiblesFrame:WaitForChild(worldFolder.Name):WaitForChild(boolValue.Name)
				local goldenToastFolderFromWorldThisCollectibleIsIn = InGame_Collectibles_Folder:WaitForChild(worldFolder.Name):WaitForChild("GoldenToast_Folder")	

				for i, goldenToastObjectModel in pairs(goldenToastFolderFromWorldThisCollectibleIsIn:GetChildren()) do

					local goldenToastObjectModelIDNumber = goldenToastObjectModel:WaitForChild("collectibleNumberOutOfTotalInSpecificWorld_NumberValue")
					local collectedStringPlusIDNumber = "Collected"..tostring(goldenToastObjectModelIDNumber.Value)

					--print(boolValue.Name,collectedStringPlusIDNumber)

					if boolValue.Name == collectedStringPlusIDNumber then

						--print("HALLO?!")

						if boolValue.Value == true then
							-- player collected this golden toast
							goldenToastUIForThisBoolValue.ImageColor3 = Color3.fromRGB(255,255,255)
							goldenToastObjectModel:WaitForChild("goldenToastMesh").Transparency = 0.35

						elseif boolValue.Value == false then
							goldenToastUIForThisBoolValue.ImageColor3 = Color3.fromRGB(0,0,0)
							goldenToastObjectModel:WaitForChild("goldenToastMesh").Transparency = 0

						end

						goldenToastObjectModel:WaitForChild("collectedBoolValue").Value = boolValue.Value

					end

				end

			end

		end
		
	elseif currentSaveFilePlayerIsPlayingOn.Value == "SaveFile3" then
		local listOfWorldBasedGoldenToastCollected_Folder = game.Players.LocalPlayer:WaitForChild("playerDataFolder").saveFile3_TableFolder.collectiblesCollectedTableFolder.listOfWorldBasedGoldenToastCollected_Folder
		local worldFoldersList = listOfWorldBasedGoldenToastCollected_Folder:GetChildren()

		for i, worldFolder in pairs(worldFoldersList) do
			local boolValues = worldFolder:GetChildren()
			--print(boolValues)
			for i, boolValue in pairs(boolValues) do
				local goldenToastUIForThisBoolValue = WorldBasedCollectiblesFrame:WaitForChild(worldFolder.Name):WaitForChild(boolValue.Name)
				local goldenToastFolderFromWorldThisCollectibleIsIn = InGame_Collectibles_Folder:WaitForChild(worldFolder.Name):WaitForChild("GoldenToast_Folder")	

				for i, goldenToastObjectModel in pairs(goldenToastFolderFromWorldThisCollectibleIsIn:GetChildren()) do

					local goldenToastObjectModelIDNumber = goldenToastObjectModel:WaitForChild("collectibleNumberOutOfTotalInSpecificWorld_NumberValue")
					local collectedStringPlusIDNumber = "Collected"..tostring(goldenToastObjectModelIDNumber.Value)

					--print(boolValue.Name,collectedStringPlusIDNumber)

					if boolValue.Name == collectedStringPlusIDNumber then

						--print("HALLO?!")

						if boolValue.Value == true then
							-- player collected this golden toast
							goldenToastUIForThisBoolValue.ImageColor3 = Color3.fromRGB(255,255,255)
							goldenToastObjectModel:WaitForChild("goldenToastMesh").Transparency = 0.35

						elseif boolValue.Value == false then
							goldenToastUIForThisBoolValue.ImageColor3 = Color3.fromRGB(0,0,0)
							goldenToastObjectModel:WaitForChild("goldenToastMesh").Transparency = 0

						end

						goldenToastObjectModel:WaitForChild("collectedBoolValue").Value = boolValue.Value

					end

				end

			end

		end
		
		
		
	end

end

I have a few comments/thoughts:

  1. If you do want to make the change that sets it to semi-transparent client side then I recommend using CollectionService tags to detect when a collectible is streamed to a client and set the transparency at that time.

  2. If this will always be a single player experience I see no reason not to just set that server side and remove the client logic for it altogether.

  3. You can change the model streaming mode dynamically if needed.

1 Like

Hi, it’s been a while since this post. Apologies for not responding sooner.

I am now doing this in my game via CollectionService:GetInstanceAddedSignal and the GetInstanceRemovedSignal in a local script (there’s an issue with that as I’ll link to later in this reply.). The issues I mentioned in the OP are now no longer an issue as I’ve decided to just keep GoldenToast Persistent.

The game is now multiplayer, as per Roblox favoring multiplayer games/connection in the algorithm. Keeping the game single player would hinder the success of my years of work.

This doesn’t fit my current situation as of now, but is something I’ll keep in mind for the future.


If I could, I’d like to turn your attention to this issue that I’ve been struggling with: GetInstanceAddedSignal Firing Twice - Need a workaround!

I’ve been hitting a wall with this and testing/progressing with development of my game has been difficult. Npcs, damaging systems, etc. all duplicated.


Thanks again,
Reditect

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.