Roblox Camera not working

  1. What do you want to achieve? I want the game camera to be following A part called “One” and this part is inside a r15 model called “CharLoader”

  2. What is the issue? The problem is everything works well in Roblox Studio but when I play on the actual Roblox the camera shows somewhere else.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local workspace = game:GetService(“Workspace”)
local charloader = workspace:WaitForChild(“CharLoader”)
local partone = charloader:WaitForChild(“One”)

gameGetService(“RunService”).RenderedStepped:connect(function()
game.Workspace.CurrentCamera.CFrame = partOne.CFrame
end)
17 Likes

You made a typo at
gameGetService(“RunService”).RenderedStepped:connect(function()
You should try

game:GetService(“RunService”).RenderedStepped:connect(function()

also, maybe consider changing the CameraType to “Scriptable”. Here is an improved version of your code:

local charloader = workspace:WaitForChild(“CharLoader”)
local partOne = charloader:WaitForChild(“One”)
local camera = game.Workspace.CurrentCamera
camera.CameraType = "Scriptable"

game:GetService(“RunService”).RenderedStepped:connect(function()
camera.CFrame = partOne.CFrame
end)
11 Likes

By re-writting your code I’ve made the same typo, it’s now fixed

Edit: Did you manage to make it work now?

3 Likes

No it’s not working like When I tested what you wrote on Roblox Studio it’s works and when I play it on Roblox it’s works too but when I go to an alt acc or my friend joins it doesn’t work the camera doesn’t work

4 Likes

Can you tell me where did you put your script, please? (Send a screenshot of your tree structure for example)

Edit: I will try to remake what your doing to see what’s not working

4 Likes

Wait I just noticed you set a variable with a name “workspace”.
But game.Workspace and workspace are literally doing the same thing.
Maybe try:

local charloader = workspace:WaitForChild(“CharLoader”)
local partOne = charloader:WaitForChild(“One”)
local camera = game.Workspace.CurrentCamera
camera.CameraType = "Scriptable"

game:GetService(“RunService”).RenderedStepped:connect(function()
camera.CFrame = partOne.CFrame
end

Edit: (yeah another edit xd) I made a small typo (again decidedly) at partOne, now changed

4 Likes

ScreenShot_20230808200441

  1. The Model in black circle is “charloader” while the thing in red circle is “one” aka what i want to be camera

ScreenShot_20230808200229

3 Likes

Oh I see what you mean, let me do it quickly on Studio.

1 Like

Have you looked in game to see where the Part One is? Is the camera at that location or somewhere completely different?
As stated, if you leave the camera unscripted it probably is trying to look at your avatar because it loads in that way.

1 Like
--SERVICE
local RS = game:GetService("RunService")
--CharLoader
local charLoader = workspace:WaitForChild("CharLoader")
local partOne = charLoader:WaitForChild("One")
--Camera
local camera = workspace.CurrentCamera
camera.CameraType = "Scriptable"

RS.RenderStepped:Connect(function()
	camera.CFrame = partOne.CFrame
end)

I put this code in a LocalScript:
image

EDIT : it works for me in Studio, and also in game

2 Likes

See I tested the things u said in Roblox
This is my main account aka the account that wrote the script in Roblox studio:

This is my alt acc :

I think it might be the part’s CFrame the issue there then.

Why don’t you make the CameraSubject the part?

Good idea, I did that for my game, I totally forgot about that. Otherwise what I’ve made earlier was working pretty well so I’m pretty sure it’s about the part’s CFrame there

Thank you, and you’re also welcome.

sorry but i dont understand
could you explain

Sure. There’s a property in a base Camera object known as CameraSubject, which essentially focuses on whatever Instance you put it on. By default it focuses on the Humanoid in the character - but you can change this to something else, for example a part.

Try to set the properties of the part “One” to:

image

And CharLoader’s ones to:

image

Actually I thiink you might want to weld the part (if you want it to follow)

I know it’s not very “clear”, but it makes the part “One” points towards CharLoader. With these properties and the code I’ve posted earlier, it works on both Studio and game