What’s good? Right,
So, I’m using this camera script for a smash bros styled game, I need it to ignore certain parts when the player dies, here’s what I’m using:
local xoffset = 0
local yoffset = 2
local zoffset = 10
local camPart = Instance.new("Part")
camPart.Anchored = true
camPart.CanCollide = false
camPart.Transparency = 1
camPart.Name = "CamPart"
camPart.Parent = workspace
local tracking = workspace.Tracking
function calculateAveragePosition()
local total = Vector3.new()
for _, humrootpart in pairs(tracking:GetChildren()) do
if workspace:FindFirstChild(humrootpart.Name) and workspace[humrootpart.Name]:FindFirstChild("Settings") and workspace[humrootpart.Name].Settings.InRound.Value == true then
total += humrootpart.Position
end
end
return total / #tracking:GetChildren()
end
function calculateAverageMagnitude()
local total = 0
for _, humrootpart in pairs(tracking:GetChildren()) do
total += (humrootpart.Position - camPart.Position).Magnitude
end
return total / #tracking:GetChildren()
end
wait()
cam.CameraType = Enum.CameraType.Scriptable
game:GetService("RunService").RenderStepped:Connect(function()
local averagePos = calculateAveragePosition()
local averageMagnitude = calculateAverageMagnitude() + zoffset
camPart.Position = averagePos
cam.CFrame = camPart.CFrame * CFrame.new(Vector3.new(xoffset, yoffset, averageMagnitude))
for _, Part in next, workspace.Tracking:GetChildren() do
if workspace:FindFirstChild(Part.Name) and workspace:FindFirstChild(Part.Name):FindFirstChild("HumanoidRootPart") then
if workspace:FindFirstChild(Part.Name):FindFirstChild("Settings") then
if workspace[Part.Name].Settings.InRound.Value == true then
Part.Position = workspace[Part.Name].HumanoidRootPart.Position
end
end
end
end
end)
Thank you!