TeleportService from place to start place not working

I want it so that when u die it sends u back to the start place. Its not working. heres th code. halp. Its literally so simple and doesnt work. when I do it in studio it says “cannot teleport while in studio” as an error which is something normal to expect i guess but like in game it does absolutely nothing it doesnt even print the weird letters I typed in to see if it gets inside of the humanoid died function. Also this is in startercharacterscripts

wait(3)

plr = game.Players:GetPlayerFromCharacter(script.Parent)

char = script.Parent

local TeleportService = game:GetService("TeleportService")

char.Humanoid.Died:connect(function()

print("AJdjsaljasldjalskd")

wait(1)

TeleportService:Teleport(2539588846, plr)

end)

Try referencing player by using LocalPlayer.

local plr = game:GetService("Players").LocalPlayer

local char = script.Parent

local TeleportService = game:GetService("TeleportService")

char:WaitForChild("Humanoid").Died:Connect(function()

  wait(1)

  TeleportService:Teleport(2539588846, plr)

end)
3 Likes

The script should function as intended. Could you have possibly used a Script instead of a Localscript?

Yes using what Abi said works now. Aren’t scripts that are located inside of startercharacterscripts global anyways? Because the script is inside the character and the character is inside workspace. I’m actually confused on how localplayer made it work in this case when a server script was being used. I thought local player can only be used in local scripts :thinking:

I think it’s because of the fact that the client has the network ownership of their character. This is also what makes character motion from the client replicate.

Correct me if I’m wrong on this one, I ain’t the expert.

I’m experiencing another problem now. The script just teleports the player to the same place they are already in rather than the start place. But I know I used the ID from the start place:

49%20PM