part
might not exist, so check if it’s not nil by doing this
if not part then
...
end
part
might not exist, so check if it’s not nil by doing this
if not part then
...
end
The CharacterCreateCamera is the Camera Part. I just checked and it’s not anchored, allow me a moment to test and see if anchoring it changes anything.
Nope, after anchoring the CharacterCreateCamera part it doesn’t seem to help. I’m getting the same output as before.
Do you see the part in your in-game explorer when doing a studio test?
No I do not. How should I fix this?
After putting in the code snippet you sent, the error disappears but the camera does not switch to the CharacterCreateCamera as it’s intended to.
If you’ve made sure it’s anchored try making sure it’s near spawn so that it’s streamed in
It’s probably because the part just doesn’t exist. First make sure it exists
Well what I’m trying to do is switch the camera’s to show different “zones” I guess. In doing so, I would need to need quite a bit of room to make each zone, so each zone is spread out. Let me show you:
Below, is the area where the camera is supposed to switch to, the one on the right.
Is there a way to stream it in if it’s at a distance like it is now?
How would I go about doing this?
First teleport the player to the area where the camera is (because of streaming) then try again
You can use Player:RequestStreamAroundAsync Player | Documentation - Roblox Creator Hub on the server then fire a remote to the client when the area is ready
I’m not quite sure how to go about doing this, as I’ve never used remote events.
I’ve adapted my code to look like this:
script.Parent.Activated:Connect(function()
local wait_time = 0.001
local CurrentCamera = workspace.CurrentCamera
local part = workspace:WaitForChild("CharacterCreateCamera", wait_time)
wait(0.001)
CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = part.CFrame
game.Lighting.TimeOfDay = 6
game.Players.LocalPlayer.PlayerGui.ScreenGui.Main.SelectSave.Main.Visible = false
game.Players.LocalPlayer.PlayerGui.ScreenGui.Main.ButtonHolders.Visible = false
game.Players.LocalPlayer.RequestStreamAroundAsync(Vector3.new(174.94, 78.1, -1030.9))
end)
I’m not quite sure if this is how it’s supposed to look with the RequestStreamAroundAsync thing, however, I’m still getting the attempt to index nil error on Line 7
first teleport the player to the spot where the part is because right now it’s just not streamed in, so the reference is nil. Do this BEFORE you use waitforchild
Create ReplicatedStorage → StartCamera (Remote Function)
Server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local cameraFunction = ReplicatedStorage.StartCamera
cameraFunction.OnServerInvoke = function(player)
player:RequestStreamAroundAsync(workspace.CharacterCreateCamera.Position)
return true
end
Client script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Lighting = game:GetService("Lighting")
local localPlayer = Players.LocalPlayer
local cameraFunction = ReplicatedStorage:WaitForChild("StartCamera")
local mainGui = localPlayer.PlayerGui.ScreenGui.Main
local currentCamera = workspace.CurrentCamera
script.Parent.Activated:Connect(function()
cameraFunction:InvokeServer()
local part = workspace:WaitForChild("CharacterCreateCamera")
currentCamera.CFrame = part.CFrame
currentCamera.CameraType = Enum.CameraType.Scriptable
Lighting.TimeOfDay = 6
mainGui.SelectSave.Main.Visible = false
mainGui.ButtonHolders.Visible = false
end)
I’ve put this in the game, and it does not seem to work. The camera doesn’t switch, but there are no errors this time.
Where did you put each script? can you screenshot your explorer
I put the server script in the Script in ReplicatedStorage and the Client script in the CharacterCreateCamera local script in the SaveSlot1 Text button
How would I go about teleporting the player to the camera part? Like I said I’m pretty beginner to scripting, so sorry lol.
Put “Script” in ServerScriptService