I am in the process of enabling streaming enabled on one of my games, but as you may already be aware some aspects of code must be adapted to accommodate this change.
I have a local script with a Touched event to a Part that does not get streamed in when a player joins the game. Since the Part is not ‘available’, the event will error, but I need the Touched event later on in the game when the player enters a zone that will be streamed in. I am struggling to think of a way to work around this, any help would be greatly appreciated.
Local Script (Run automatically when player enter game):
local Touch_P1 = game.Workspace:WaitForChild("Part1")
Touch_Speedrun_C1.Touched:Connect(function(hit) <-- Errors (nil)
--Code
end)
i dont really know much about streaming enabled but if there is like a LoadIn(“Part”) do that. Other than that maybe busy wait on the client
local isClose = false
local event = nil
game:GetService("RunService").Heartbeat:Connect(function()
if workspace:FindFirstChild("Part1") and not isClose then
isClose = true
event = Touch_Speedrun_C1.Touched:Connect(function(hit) <-- Errors (nil)
--Code
end)
elseif event then
pcall(function()
event = nil
isClose = false
end)
end
end)