Streaming Enabled Issue!

Recently I toggled on streaming enabled.

Now I am noticing some errors in my scripts. One being where I am creating a part via Instance.new on the server, then firing to client that part as an argument for the client to pick up and do effects visually on the client.

But now an error occurs claiming that part is ‘nil’ on the client.

I figured it may be because i toggled streaming enabled recently.

How can I fix?

Hey. This is not a bug, but a functionality.
Let me explain: The instance is nil because it hasn’t been replicated to the client from the server due to some reasons, one could be that your client is just far away and cannot see the instance, so server won’t replicate it.
By enabling Streaming you’re going through one more step when player joins the server. If you’re sending an Instance when player joins the game, it probably won’t work since the server has not replicated the instance yet.
Either you could set the instance to always replicate ignoring streaming rules, or you handle the error on client checking if Instance exists.
I recommend reading how Content Streaming works.

1 Like

Hi, can you help me on solving this issue?

How can I make it so a part that I make on the server via instance.new(“part”)

then fireallclients(part)

client script: onclientevent(function(partreceived) local NewPart = partreceived

How can I make it so the client doesn’t error because it hasn’t rendered / detected the part, even though the server made it

Why do you need streaming enabled?
And what is exact use case you need to do with creating instance and then right away sending an event?

Instead of sending the instance you can send it’s name or path, so client can use WaitForChild, if you’re sure that the instance will be streamed in after creation. There are some ways how to solve it.

Provide your current code.

Because streaming enabled helps with optimisation with the map.


														local Part = Instance.new("Part")
														Part.Position = RaycastResult.Position
Part.Anchored = true
Part.Parent = workspace.Effects
														Part.CFrame = Part.CFrame * CFrame.new(0,4,0)
														BV:Destroy()
														game.ReplicatedStorage.Events.Client:FireAllClients("FloorSmashEffect", Part)

game.ReplicatedStorage.Events.Client.OnClientEvent(function(arg, model)
  if arg == "FloorSmashEffect" then
   ....
    Character.PrimaryPart.Position = model.Position  
       --Errors here saying model is nil

end

end)

You need to check if model exists on the client before running anything. I recommend looking into using CollectionService:GetInstanceAddedSignal for visual effects on the client with streaming enabled though as that’s what my game does and it works pretty well for me.

Please give an example with what you stated

Hey, please can you elaborate on this

If you’re asking about GetInstanceAdded it’s something that’s useful for streaming enabled related client side stuff. Whenever a part is rendered that has a certain CollectionServiceTag if the tag matches the tag the function is listening for it will run that function. If your asking about the model thing you can just check if the model == nil on the client and if it does than return end.

2 Likes