Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

says line 17 is indexing a nil value? [closed]

Asked by 5 years ago
local viewPort = script.Parent:WaitForChild("ViewportFrame")
local playerAro = script.Parent.ViewportFrame.Player


local WildLife = workspace:WaitForChild("WildLife")
--WildLife:Clone().Parent = viewPort
local cild = game.Workspace:GetChildren()
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()

for index = 1, #cild do
    if cild[index].Name ~= "Camera" then
        if cild[index].Name ~= "Terrain" then
            if cild[index].Name ~= nil then
                if cild[index].Parent ~= nil then
                    print(cild[index].Name)
                    cild[index]:Clone().Parent = viewPort
                end
            end
        end
    end
end

local camera = Instance.new("Camera",workspace)
camera.CameraType = Enum.CameraType.Scriptable

local height = 50

viewPort.CurrentCamera = camera

game:GetService("RunService").RenderStepped:Connect(function()
    local pos = player.Character.HumanoidRootPart.Position
    camera.CFrame = CFrame.new(Vector3.new(pos.X,height,pos.Z),pos)
    playerAro.CFrame = player.Character.HumanoidRootPart.CFrame
end)

Closed as Too Broad by User#24403 and TheeDeathCaster

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?