#Camera script
11 messages · Page 1 of 1 (latest)
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local stage = plr:WaitForChild("leaderstats"):FindFirstChild("Stage")
local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")
local TeleportEvent = ReplicatedStorage:FindFirstChild("TeleportEvent")
plr.CharacterAdded:Connect(function(char)
game.Workspace.CurrentCamera.CFrame = char:WaitForChild("Head").CFrame
game.Workspace.CurrentCamera.Focus = char:WaitForChild("Head").CFrame
end)
TeleportEvent.OnClientEvent:Connect(function(toched)
if toched == true then
game.Workspace.CurrentCamera.CFrame = game.Workspace[plr.Name].Head.CFrame
game.Workspace.CurrentCamera.Focus = game.Workspace[plr.Name].Head.CFrame
end
end)
this is for an obby
Could you tell me where this script is located in the studio hierchy
StarterPlayerScripts
i wouldnt use waitforchild so often as it could wait potentially forever as you have already waited for the character to load, and once that loaded you neednt wait for child on the other things
also you dont need to wait for the character added
game.Workspace.CurrentCamera.CFrame = char:WaitForChild("Head").CFrame
game.Workspace.CurrentCamera.Focus = char:WaitForChild("Head").CFrame
just have that
since you already defined character just do
game.Workspace.CurrentCamera.CFrame = character:FindFirstChild("Head").CFrame
game.Workspace.CurrentCamera.Focus = charcter:FindFirstChild("Head").CFrame
now im not good with CFrame so thats like as far as i go ngl im sorry