#Camera
15 messages · Page 1 of 1 (latest)
Don't put scripts in workspace
Also it should be a local script if you want to access the camera.
the scripts thing does matter, putting it in workspace It doesn't matter technically, but it's bad practice.
One is meant for scripts the other is not, server script service also hides your scripts from the client so the client never needs to replicate it and exploiters can't get to it.
You should really use RenderStepped for moving the camera as well because the camera is what's used to render anyways.
And it would be smoother
The first one of course, but the second one won't error if part doesn't exist.
Let me make a script for you real quick.
-- Localscript in StarterPlayerScripts
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
RunService.RenderStepped:Connect(function()
-- get character
local character = player.Character
if not character then return end
-- get local camera and make it scriptable
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
-- get hrp for reference position
local hrp = character.PrimaryPart
if not hrp then return end
-- camera position (this assumes the map is going in the default direciton.
local camOffsetPos = CFrame.new(hrp.CFrame.Position) * CFrame.new(10, 10, 20)
-- you could create some cool effects by calculating the offset separate from the rotation but I didn't do that here.
local rotated = camOffsetPos * CFrame.Angles(0, math.rad(-45), 0)
-- move camera to correct position
cam.CFrame = rotated
end)
WaitForChild is most likely slower but idk they're pretty much the same I'd imagine.
You didn't use the magic words
Well I did say that it should be a local script in starterplayerscripts
so
that's what you're doing wrong
** You are now Level 2! **