Game is not a valid member of Datamodel "Untitled Game"

I have been searching for a solution, but no luck…

So I made a simple script that tweens the camera from one part to another four seconds after the player has loaded. But after testing it, this error popped up…

image

My code: ```lua
local currentcamera = game.Workspace.CurrentCamera
local campart1 = game.game.Workspace.Cameras.cam1
local campart2 = game.Workspace.Cameras.cam2

currentcamera.CameraType = Enum.CameraType.Scriptable
currentcamera.CFrame = campart1.CFrame

repeat wait(1) until game:IsLoaded()

wait(4)

local tweenservice = game:GetService(“TweenService”)

tweenservice:Create(currentcamera, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {
CFrame = campart2.CFrame
}):Play()```

I think this is a Roblox issue.
Thanks!

You have “game.game” in your second variable, remove the extra “game”

1 Like

change this

local campart1 = game.game.Workspace.Cameras.cam1

to this

local campart1 = game.Workspace.Cameras.cam1

or just do the post above me

2 Likes

Thanks, forgot to catch that issue!

But I have this new error.

Which makes no sense because Cameras IS a valid member of workspace
image

This is because the Cameras folder hasn’t replicated yet, since your script is running before anything replicates, since its in ReplicatedFirst, you should use a :WaitForChild() call to wait for Cameras to replicate/load in.

Anything in ReplicatedFirst gets loaded in before anything else.

2 Likes