Help with player teleport

Essentially, I’m making a script that teleports characterWhoNeedsRescuing's PrimaryPart (in this case, HRP, does this mean that everything else in the character will move with it?) to characterWhoIsRescuing's PrimaryPart.

Problem is, it’s doing as I ask and moving just the HRP, but I’m trying to get the entire character model to move to characterWhoIsRescuing.

local sp = script.Parent

local function setHealth(humanoid, amount)
	humanoid.Health = amount
end

rescued = false

sp.MouseClick:Connect(function(clicker)
	local characterWhoIsRescuing = workspace:FindFirstChild(clicker.Name)
	local characterWhoNeedsRescuing = script.Parent.Parent
	
	local rescueTPPoint = characterWhoIsRescuing.PrimaryPart.Position
	characterWhoNeedsRescuing.PrimaryPart.Position = rescueTPPoint
	rescued = true
	
	setHealth(characterWhoNeedsRescuing:FindFirstChild("Humanoid"), 100)
	sp:Destroy()
end)

Can anyone help me please?

Change the HRP’s CFrame instead of its Position

So I do CFrame.Position rather than Position?

No, do this:

	local rescueTPPoint = characterWhoIsRescuing.PrimaryPart.CFrame
	characterWhoNeedsRescuing.PrimaryPart.CFrame = rescueTPPoint

You have to change the primary part of the character model.

This is working only with CFrame. Use @DataSigh script.

No.

1 Like

Meant to change the CFrame of the primary part.

1 Like

I think this is the right version.

Well when teleporting a player to a specific location in your game, you’d want to move their CFrame instead of their Position.

In fact when moving any part or model, you should always opt on using the CFrame

In your case I would write this:

local RescueButton = script.Parent
local Rescued = false

function SetHealth(humanoid)
   humanoid.Health = 100
end

RescueButton.MouseClick:Connect(function(Clicker)
   local CharacterRescuing = workspace:FindFirstChild(Clicker.Name)
   local CharacterRescued = script.Parent.Parent
   local EndPoint = CharacterRescuing.PrimaryPart.CFrame

   CharacterRescued.PrimaryPart.CFrame = EndPoint
   Rescued = true
   SetHealth(CharacterRescued:FindFirstChild("Humanoid"))
   wait()
   RescueButton:Destroy()
end)

Not exactly sure why you’d wanna destroy the scripts parent, but if it’s a GUI, then you can make it invisible instead.

1 Like