Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone tell me how to fix player death on teleport?

-- Variables
local player = game.Players.LocalPlayer
local a = game.ReplicatedStorage.AeikeTitan:Clone()
local b = game.ReplicatedStorage.Lightning:Clone()
local c = game.ReplicatedStorage.Steam:Clone()
local rep = game.ReplicatedStorage


-- Functions

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.J and script.isTitan.Value == false then -- gets the key and isTitan value
		print("Titan Shift in action") -- for debugging
		b.Parent = game.Workspace
		b:SetPrimaryPartCFrame(player.Character.Torso.CFrame)
		script.Bolt:Play()
		wait(1)
		a.Parent = game.Workspace
		a.Name = "Titan"..player.Name
		a:SetPrimaryPartCFrame(player.Character.Torso.CFrame)
		local weld1 = Instance.new("ManualWeld", a)
		weld1.Part0 = player.Character.Torso
		weld1.Part1 = a.Head
		game.Workspace.CurrentCamera.CameraSubject = a.Head
		player.Character.Torso.CFrame = player.Character.Torso.CFrame * CFrame.fromEulerAnglesXYZ(90,0,0)
		player.Character:SetPrimaryPartCFrame(a:FindFirstChild("Head").CFrame)
		script.TitanRoar:Play()
		player.Character.Torso.Anchored = false
		wait(0.1)
		b:Destroy()
		wait(0.1)
		script.isTitan.Value = true
		wait(30)
		script.isTitan.Value = false
		a.ManualWeld:Destroy()
		a:Destroy()
		player.Character.Humanoid.WalkSpeed = 16
		game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Head
	end
	end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

-- TITAN TELEPORTATION
if script.isTitan == false then
	a:Destroy()
end

end

for some reason this script kills the player its a local script any help preventing that?

1 answer

Essentially what you are doing is moving the torso of the player only, not the player by setting the primary part of the torso. Think about what would happen in real life if you did that. The easiest way to teleport is to just CFrame a player's HumanoidRootPart, which will move the rest of the player's limbs with them.

-- void teleport(Model playermodel, Vector3 location)
function teleport(playermodel, location)
	playermodel.HumanoidRootPart.CFrame = CFrame.new(location)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.