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

How would I get the LocalPlayer to spawn at the position when they die in the CFrame?

I am stumped on how I would get the LocalPlayer to teleport to the position set when the player is dead/health = 0.. Could anyone help me with this?


Player = script.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Down:Connect(function()
	Player.Team = game.Teams.Blue
	wait(.05)
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(39.3, 0.6, -71.35))
	wait(.05)
end)

3 comments

0

Please, use LocalPlayer and not script.Parent.Parent.Parent.Parent. And use local variables.

0

ok i'm presuming this is a local script so #1, Set the position of the player on the server, #2, use SetPrimaryPartCFrame() instead of setting the humanoid root part cframe, #3 why use a gui button when you want to check if the player is dead, #4, change the player's team in a server script, #5 why bother using game.Players.LocalPlayer when you have a player variable

0

Ok guys thanks for answering my question it helps a lot!

1 answer

✓ Accepted answer

First get died function then teleport, easy sauce :}

-- localscript:

repeat wait() until game.Players.LocalPlayer

local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid = char:WaitForChild("Humanoid") -- find the health = 0 thingie thing
local Pos = Vector3.new(0,0,0) -- starting position, change to the Spawn point
humanoid.Died:Connect(function()
	local Pos = char.UpperTorso.Position
wait(5)
	  game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(Pos))
end)

This is some untested code, most of my untested code doesn't work but I mean, you are a good scripter and you will find out how to fix it...

IF YOU ARE USING R6 change the variable Pos to char.Torso.Position The player will start the game at Vector3.new(0,0,0) so you might want to change that lool.

I tried...

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