So basically I am trying to make a HeadCamera like the one in the video shown below.
But I don’t really know how to make it lock, or how to hide the hats so you can see it normally.
I tryed using CFrames to make it so it work go into the head but it would only tp to the head once and stay there (even if the player was still moving)
local Players = game:GetService("Players")
local playerLabel = script.Parent:WaitForChild("PlayerLabel")
local uis = game:GetService("UserInputService")
local cam = workspace.CurrentCamera
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local isSpectating = false
local currentIndex = 1
local playerList = {}
local function updatePlayers()
local newPlayerList = {}
for plrs, plr in pairs(Players:GetPlayers()) do
if plr ~= game.Players.LocalPlayer then
table.insert(newPlayerList, plr.Name)
end
end
playerList = newPlayerList
end
local function updateSpectator()
local foundPlayer = Players:FindFirstChild(playerList[currentIndex])
if foundPlayer then
playerLabel.Text = foundPlayer.Name
cam.CameraSubject = foundPlayer.Character.Head
end
end
local function nextPlayer()
if currentIndex < #playerList then
currentIndex += 1
else
currentIndex = 1
end
updateSpectator()
end
local function lastPlayer()
if currentIndex > 1 then
currentIndex -= 1
else
currentIndex = #playerList
end
updateSpectator()
end
local function quitSpectating()
cam.CameraSubject = hum
currentIndex = 1
end
hum.Died:Connect(function(player)
script.Parent.static.Enabled = true
script.Parent.Parent.Enabled = true
isSpectating = not isSpectating
script.Parent.Visible = isSpectating
if isSpectating then
updatePlayers()
updateSpectator()
else
quitSpectating()
end
end)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Left then
lastPlayer()
end
if input.KeyCode == Enum.KeyCode.Right then
nextPlayer()
end
end)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.ButtonL1 then
lastPlayer()
end
if input.KeyCode == Enum.KeyCode.ButtonR1 then
nextPlayer()
end
end)
Two videos
Uploading: 2023-06-14 11-00-53.mp4…
Uploading: 2023-06-15 20-17-52.mp4…
sorry if there is sensitive stuff in the video of Ready Or Not