Hello, I am trying to make a camera stuck at one place, but it doesn’t seem to be working for me
Here is the script
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local part = game.Workspace:WaitForChild("CameraPart")
player.CharacterAdded:Connect(function()
if camera.CameraType ~= Enum.CameraType.Scriptable then
repeat wait() camera.CameraType = Enum.CameraType.Scriptable until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = part.CFrame
end
end)
My guess is that you put this in StarterGui.
CharacterAdded won’t fire since objects in StarterGui gets added after the character. You could, however, fire a Remote event from the server. This will fire everytime the character gets added:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
game.ReplicatedStorage.Camera:FireClient(plr) --Fire the event
end)
end)
And then simply change CharacterAdded to the event:
local camera = workspace.CurrentCamera
local part = game.Workspace:WaitForChild("CameraPart")
game.ReplicatedStorage.Camera.OnClientEvent:Connect(function()
if camera.CameraType ~= Enum.CameraType.Scriptable then
repeat wait() camera.CameraType = Enum.CameraType.Scriptable until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = part.CFrame
end
end)