Hi, I have a problem.
SITUATION: I have streaming enabled this I require the use of :FindFirstChild, to check if the model is in workspace exist before proceeding with anything else.
PROBLEM: My :FindFirstChild says that the model does not exist, even though it is clearly loaded in the client (It is right infront of my. I am clearly seeing it.)
Here is the script, it is a local script.
if workspace:FindFirstChild("Train") == true then
TrainFloor = game.Workspace:WaitForChild("Train", 30):WaitForChild(TRAIN_BASE_NAME)
table.insert(Include, TrainFloor)
else
print("e")
end
It keeps on printing āEā, indicating the model is not in the client workspace even though it clearly is.
Not sure if this matters, but heres the whole script:
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')
local LastTrainCFrame
local Function
local Function2
local TRAIN_BASE_NAME = "TrainFloor"
local DoOnce = false
local LastHit = nil
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Include
local RootPart = player.Character:WaitForChild("Right Leg")
local Include = { }
local TrainFloor = nil
Function = RunService.Heartbeat:Connect(function()
TrainFloor = nil
table.clear(Include)
if workspace:FindFirstChild("Train") == true then
TrainFloor = game.Workspace:WaitForChild("Train", 30):WaitForChild(TRAIN_BASE_NAME)
table.insert(Include, TrainFloor)
else
print("e")
end
TrainFloor = nil
raycastParams.FilterDescendantsInstances = Include
local result = workspace:Raycast(RootPart.CFrame.p, Vector3.new(0, -500, 0), raycastParams)
if not result then
return --nothing below the character
end
local Hit, Position, Normal, Material = result.Instance, result.Position, result.Normal, result.Material
--------------------------------
--print(Hit.Name)
if DoOnce == false then
DoOnce = true
LastHit = Hit
end
if LastHit == Hit then
--Do Nothing
elseif LastHit ~= Hit then
LastHit = Hit
LastTrainCFrame = nil
end
local Train = nil
local TrainCF = nil
local Rel = nil
if Hit and player.Character.Humanoid.Sit == false then
--print("slay")
-- MOVE PLAYER TO NEW POSITON FROM OLD POSITION:
Train = Hit
if LastTrainCFrame == nil then -- If no LastTrainCFrame exists, make one!
LastTrainCFrame = Train.CFrame -- This is updated later.
end
TrainCF = Train.CFrame
Rel = TrainCF * LastTrainCFrame:inverse()
LastTrainCFrame = Train.CFrame -- Updated here.
RootPart.CFrame = Rel * RootPart.CFrame -- Set the player's CFrame
else
LastTrainCFrame = nil
Train = nil
TrainCF = nil
Rel = nil
end
end)
All help is appreciated