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
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
ServerScript
IntoStarterCharacterScripts
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.
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