when I try to teleport the player's HumanoidRootPart using CFrame, the HumanoidRootPart is moving perfectly, but it's not connected to the body of the player (hands, arms, legs, etc..) please tell me how do I fix this please
How do I fix the teleporting problem when using CFrame?
2 answers
Hi, I'm BlackOrange and I will be helping you.
So, you don't actually need 2 scripts.
I will help you:
- Remove all the scripts you got for this respawn things and also remove the remote event (Optional)
- Insert a
ServerScriptIntoStarterCharacterScripts
- Start by variables alone:
local Char = script.Parent
local plr = game.Players:GetPlayerFromCharacter(Char)
-- This script will only run 1 time because it is in StarterCharacterScripts. This means you don't need an event. Unless there is a loop or event this will run 1 time
Char.Humanoid.Died:Connect(function()
plr:LoadCharacter()
wait()
Char.HumanoidRootPart.CFrame = CFrame.new(plr.Checkpoint.Value.X,plr.Checkpoint.Value.Y+4,plr.Checkpoint.Value.Z)
end)
Char.Humanoid.HealthChanged:Connect(function(Health) -- this is backup incase Died doesn't work, I find Died fairly buggy
if Health <= 0 then
plr:LoadCharacter()
wait()
Char.HumanoidRootPart.CFrame = CFrame.new(plr.Checkpoint.Value.X,plr.Checkpoint.Value.Y+4,plr.Checkpoint.Value.Z)
end
end)
--[[
Char.HumanoidRootPart.CFrame = CFrame.new(plr.Checkpoint.Value.X,plr.Checkpoint.Value.Y+4,plr.Checkpoint.Value.Z)]]--
Your Character should automatically respawn, this means you technically don't need :LoadCharacter()
Hopefully this helped.
Best of luck developer!
EDIT: Now works for instant respawn.
2 comments
I used :LoadCharacter() because I want the character to spawn instantly, and what I meant is not that, I meant when you teleport, your body falls off, but it does the moving animations when I move the HumanoidRootPart using my keyboard
Well you may have noticed I used CFrame instead of Position
game.ReplicatedStorage.Respawn.OnServerEvent:Connect(function(plr)
wait(1)
local human = plr.Character.HumanoidRootPart
human.Position = Vector3.new(plr.Checkpoint.Value.X,plr.Checkpoint.value.Y+4,plr.Checkpoint.Value.Z)
end)
this code will be executed after this script:
local Humanoid = script.Parent:WaitForChild('Humanoid')
local plr = game.Players:GetPlayerFromCharacter(script.Parent)
Humanoid.Died:Connect(function()
local stg = plr.Checkpoint.Value
game.ReplicatedStorage.Respawn:FireClient(plr,plr)
plr:LoadCharacter()
end)
it also receives it from a local script then that local script fires a server event that executes the first script above
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Post your script.
ok