so im making some cutsenes but now im teleporting an npc and after i teleported it it stucks and freezes in air for a while even trough all parts are unanchored so i expect pysics to apply
-- teleporting
local NPCCharProfUNew = Functions.FindNPC(player, "prof-unviere-R6")
if NPCCharProfUNew then
local Char = CharClass.newChar(NPCCharProfUNew) -- create a new charcter object
Char:GetHumanoidRootPart().CFrame = NPCNodes.ProfUnviereWalkToLab.Spawn.Start.CFrame teleport the npc with the humanoid root part
else -- if not npc existing create a new one
StoryComm:FireServer("RunFunction", "CreateNewNpc", {
NPCNodes.ProfUnviereWalkToLab.Spawn.Start,
"prof-unviere-R6",
false
})
end
You’re setting the CFrame of HumanoidRootPart from the client it looks like, until the server owns the rig, physics won’t step, so it hovers.
local RS = game:GetService("ReplicatedStorage")
local TeleportNPC = RS:WaitForChild("TeleportNPC") -- RemoteEvent
-- Unanchor all parts, zero velocity, give the server network ownership.
-- Also ensure Humanoid isn't stuck in PlatformStand.
local function prep(model: Model)
for _, d in ipairs(model:GetDescendants()) do
if d:IsA("BasePart") then
d.Anchored = false -- unanchor
d.AssemblyLinearVelocity = Vector3.zero -- clear motion
pcall(function() d:SetNetworkOwner(nil) end) -- server owns physics
end
end
local hum = model:FindFirstChildOfClass("Humanoid")
if hum then hum.PlatformStand = false end -- allow normal sim
end
-- Do the move on the server, not client.
TeleportNPC.OnServerEvent:Connect(function(player)
local npc = Functions.FindNPC(player, "prof-unviere-R6")
if not npc then
StoryComm:FireServer("RunFunction","CreateNewNpc",{
NPCNodes.ProfUnviereWalkToLab.Spawn.Start,
"prof-unviere-R6",
false
})
return
end
prep(npc)
-- Move the whole Model (not just the HumanoidRootPart).
npc:PivotTo(NPCNodes.ProfUnviereWalkToLab.Spawn.Start.CFrame)
end)
using the server worked but i dont abuse remote events just use argument to diff remote events like action, ... where … are all needed args
-- client
local NPCCharProfUNew = Functions.FindNPC(player, "prof-unviere-R6")
if NPCCharProfUNew then
local Char = CharClass.newChar(NPCCharProfUNew)
Char:GetHumanoidRootPart().CFrame = NPCNodes.ProfUnviereWalkToLab.Spawn.Start.CFrame
StoryComm:FireServer("RunFunction", "TPNPC", {
"prof-unviere-R6",
NPCNodes.ProfUnviereWalkToLab.Spawn.Start,
5
}, CutseneID)
else
StoryComm:FireServer("RunFunction", "CreateNewNpc", {
NPCNodes.ProfUnviereWalkToLab.Spawn.Start,
"prof-unviere-R6",
false
}, CutseneID)
end
-- server function
Functions.TPNPC = function(Player:Player, CutseneID, NPCName:string, TPPart:BasePart, YOffset)
local NPCFolder = game.Workspace.Dynamic:FindFirstChild("NPCS")
if NPCFolder then
local PlrNpcs = NPCFolder:FindFirstChild("Npcs_"..Player.UserId)
if PlrNpcs then
local NPCToTP = PlrNpcs:FindFirstChild(NPCName)
if NPCToTP then
local NPC = CharClass.newChar(NPCToTP)
NPC:GetHumanoidRootPart().CFrame = TPPart.CFrame + Vector3.new(0, YOffset, 0)
end
end
end
end
its fixed by using the server so im mark your as solution only
this wont work on the server script that function basicaly calls an function in the server module but can only be send from the client