Hello People, I am doing a History Game, I added Cutscenes and what not, I have a problem right now, So i am trying to Anchor The Character RootPart for when a Cutscene plays, all locally, I don’t intend to add Server replication because, In a scenario where there is 2 players, i want them to see their own character, if i did this in the server those 2 player character would probably overlap in the same position, which is not what i want
I am having trouble settings the CFrame , because it’s inaccurate, What i do is Anchor first, then PivotTo, but it always does this :
For reference, this is how it should actually look (Perfectly in the ground)
This Is my Gameplay Script :
["SleepingSequence"] = {
event = EventsRegisterModule:Register("SleepingSequence", {
Requires = { "Exploration_Ended" },
TriggerOnRegister = false,
OnTrigger = function(name, payload)
for _, player in GetPlayers() do
local Character = player.Character
local Humanoid: Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
local RootPart = Humanoid.RootPart
end
self.AudioPacket:Fire("Stop", { fadeOutTime = 1.5 })
self.TransitionPacket:Fire(true, { fadeInTime = 2.0 })
for _, player in GetPlayers() do
B_StatsService.playerStats:AddModifier({
player = player,
path = "Movement.Speed",
value = 0,
type = "Override",
source = "Stun",
priority = 200,
tags = { "debuff", "cc" },
})
end
task.wait(3)
warn("FADE OUT")
task.wait(1.5)
self.TransitionPacket:Fire(false, { fadeOutTime = 3.5 })
self.AudioPacket:Fire("Set", {
assetid = "rbxassetid://126382515627306",
play = true,
volume = 0.8,
fadeInTime = 0.01,
playbackspeed = 1,
})
for _, player in GetPlayers() do
local Character = player.Character
local Humanoid: Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
local RootPart = Humanoid.RootPart
AnimationsServer:PlayTrack(player, {"Cutscenes", "SleepSequence"})
end
self.CamCinematicOnPart:Fire(SleepSequencePos2, sleep1, true, SleepSequencePos2, true)
end,
OnRegister = function(name, event)
print(name .. " registered")
end,
}),
},
}
This is The CutsceneController, I am using the playCinematicOnRootPart Function
-- CameraController
task.wait(0.20)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local PacketNetwork = require("@game/ReplicatedStorage/Modules/crucial/PacketNetwork")
local Controller = {}
local camera = workspace.CurrentCamera
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local head = character:WaitForChild("Head")
local isCinematicActive = false
local isLooking = false
local lookConnection = nil
local activeConnection = nil
local function setCharacterTransparency(modifier: number)
for _, child in character:GetChildren() do
if child:IsA("BasePart") then
child.LocalTransparencyModifier = modifier
elseif child:IsA("Accessory") then
local handle = child:FindFirstChildWhichIsA("BasePart")
if handle then
handle.LocalTransparencyModifier = modifier
end
end
end
end
local function restoreCamera(savedCFrame: CFrame, goToHead: boolean, savedFov: number)
humanoid.AutoRotate = true
camera.CameraType = Enum.CameraType.Custom
if goToHead then
local tweenInfo = TweenInfo.new(0.8, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
TweenService:Create(camera, tweenInfo, { CFrame = head.CFrame }):Play()
else
camera.CFrame = savedCFrame
end
local fovTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
TweenService:Create(camera, fovTweenInfo, { FieldOfView = savedFov }):Play()
end
local function disconnectActive()
if activeConnection then
activeConnection:Disconnect()
activeConnection = nil
end
end
local function forceReset()
disconnectActive()
if isLooking and lookConnection then
lookConnection:Disconnect()
lookConnection = nil
end
isLooking = false
camera.CameraType = Enum.CameraType.Custom
camera.FieldOfView = 70
humanoid.AutoRotate = true
setCharacterTransparency(1)
isCinematicActive = false
end
local function lookAt(targetInstance: Instance, duration: number)
if isCinematicActive or isLooking then return end
isLooking = true
lookConnection = RunService:BindToSimulation(function(_dt)
local lookDir = CFrame.new(camera.CFrame.Position, targetInstance.Position)
local newCFrame = CFrame.new(camera.CFrame.Position) * lookDir
camera.CFrame = camera.CFrame:Lerp(newCFrame, 0.15)
end, Enum.StepFrequency.Hz60)
task.delay(duration + 0.1, function()
if lookConnection then
lookConnection:Disconnect()
lookConnection = nil
end
isLooking = false
end)
end
local function playCinematic(folder: Folder, showBody: boolean, goToHead: boolean)
if isCinematicActive then return end
task.wait()
isCinematicActive = true
local savedCFrame = camera.CFrame
local savedFov = camera.FieldOfView
local frameTime = 0
humanoid.AutoRotate = false
camera.CameraType = Enum.CameraType.Scriptable
local fovTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
TweenService:Create(camera, fovTweenInfo, { FieldOfView = 68 }):Play()
if showBody then
setCharacterTransparency(0)
end
activeConnection = RunService.RenderStepped:Connect(function(dt)
frameTime += dt * 60
local frameIndex = math.ceil(frameTime)
local neededFrame = folder.Frames:FindFirstChild(tostring(frameIndex))
if neededFrame then
camera.CFrame = neededFrame.Value
else
disconnectActive()
if showBody then
setCharacterTransparency(1)
end
restoreCamera(savedCFrame, goToHead, savedFov)
isCinematicActive = false
end
end)
end
local function playCinematicOnRootPart(referencePart: BasePart, folder: Folder, TeleportPlayer: boolean, PartOrCFrame: BasePart | CFrame, AnchorRootPart: boolean)
if isCinematicActive then return end
isCinematicActive = true
local savedCFrame = camera.CFrame
local frameTime = 0
task.spawn(function()
humanoid.AutoRotate = false
player.CameraMinZoomDistance = 999
end)
task.wait(0.15)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = camera.CFrame * CFrame.Angles(0, 0, 0)
task.spawn(function()
if TeleportPlayer then
local char = player.Character
if not char then return end
local hum: Humanoid = char:FindFirstChildWhichIsA("Humanoid")
local root = hum and hum.RootPart
if not root then return end
if AnchorRootPart then
root.Anchored = true
end
if typeof(PartOrCFrame) == "Instance" and PartOrCFrame:IsA("BasePart") then
char:PivotTo(PartOrCFrame.CFrame)
elseif typeof(PartOrCFrame) == "CFrame" then
char:PivotTo(PartOrCFrame)
end
warn("Anchored then Moved Character — no float")
end
end)
activeConnection = RunService.RenderStepped:Connect(function(dt)
frameTime += dt * 60
local frameIndex = math.ceil(frameTime)
local neededFrame = folder.Frames:FindFirstChild(tostring(frameIndex))
if neededFrame then
camera.CFrame = referencePart.CFrame * neededFrame.Value
else
disconnectActive()
humanoid.AutoRotate = true
camera.CameraType = Enum.CameraType.Custom
player.CameraMinZoomDistance = 0.5
camera.CFrame = savedCFrame
isCinematicActive = false
if AnchorRootPart then
local char = player.Character
local hum: Humanoid = char and char:FindFirstChildWhichIsA("Humanoid")
if hum and hum.RootPart then
hum.RootPart.Anchored = false
end
end
end
--end)
end)
end
function Controller.init(self)
self.container = script
self.networking = {
["CamCinematic"] = PacketNetwork("CamCinematic", PacketNetwork.Any, PacketNetwork.Boolean8, PacketNetwork.Boolean8),
["CamLookAt"] = PacketNetwork("CamLookAt", PacketNetwork.Any, PacketNetwork.NumberU8),
["CamCinematicOnPart"] = PacketNetwork("CamCinematicOnPart", PacketNetwork.Any, PacketNetwork.Any, PacketNetwork.Boolean8, PacketNetwork.Any, PacketNetwork.Boolean8),
}
print(self.container.Name .. " initialized")
end
function Controller.start(self)
print(self.container.Name .. " started")
player.CharacterAdded:Connect(function(newCharacter)
forceReset()
character = newCharacter
humanoid = newCharacter:WaitForChild("Humanoid")
head = newCharacter:WaitForChild("Head")
end)
-- Packet listeners (client-side receive)
self.networking.CamCinematic.OnClientEvent:Connect(function(folder: Folder, showBody: boolean, goToHead: boolean)
if not folder then
warn("[CameraController] CamCinematic received without a folder.")
return
end
playCinematic(folder, showBody, goToHead)
end)
self.networking.CamLookAt.OnClientEvent:Connect(function(targetInstance: Instance, duration: number)
if not targetInstance then
warn("[CameraController] CamLookAt received without a target.")
return
end
lookAt(targetInstance, duration)
end)
self.networking.CamCinematicOnPart.OnClientEvent:Connect(function(referencePart: BasePart, folder: Folder, TeleportPlayer: boolean, PartOrCFrame: BasePart | CFrame, AnchorRootPart: boolean)
if not TeleportPlayer then TeleportPlayer = false end
if not referencePart or not folder then
warn("[CameraController] CamCinematicOnPart received with missing arguments.")
return
end
playCinematicOnRootPart(referencePart, folder, TeleportPlayer, PartOrCFrame, AnchorRootPart)
end)
end
return Controller
At first i tried things like task.spawn and task.defer in many orders, but none worked

