Hi everyone, been scratching my head at this issue I’m having with a localscripts doortween. Sometimes I load into studio to test and it’s fine, door works as intended. But sometimes, I’ll load in and HotelDoorDetect is nil, and never gets found.
I’ve tried defining HotelDoorDetect using Waitforchild before the loop, alongside multiple waitforchilds for the Building, and Scriptables parts, neither solve this issue.
StreamingEnabled is false, the HotelDoorDetect part is Anchored, and exists in the client view explorer when in game.
I’ve done a lot of printing debugging, in the events that it can’t find HotelDoorDetect it’'s when the localscript recognises that “Scriptables” has 0 children.
In all the information I can find on the matter, they’ve said that you can use waitforchild on its parents as well, does not work.
local Replicated = game:GetService("ReplicatedStorage")
local OthFunctions = require(Replicated.ModuleScripts.LocalMovements)
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Runservice = game:GetService("RunService")
Runservice.Heartbeat:Connect(function()
local Char = LocalPlayer.Character
local HotelDoorDetect = game.Workspace["Building"].Scriptables:FindFirstChild("FrontDoorDetect")
if HotelDoorDetect and Char and Char:FindFirstChild("HumanoidRootPart") then
if (HotelDoorDetect.Position - Char.HumanoidRootPart.Position).Magnitude <= 10 and HotelDoorDetect.LocalOpenDoorVal.Value == false then
OthFunctions.opendoor("Front", true)
elseif (HotelDoorDetect.Position - Char.HumanoidRootPart.Position).Magnitude >= 10 and HotelDoorDetect.LocalOpenDoorVal.Value == true then
OthFunctions.opendoor("Front", false)
end
end
end)
Thank you!