local pp = script.Parent
local tpservice = game:GetService("TeleportService")
local place = 14651344381
pp.Triggered:Connect(function()
local Player = game.Players.LocalPlayer
tpservice:Teleport(place, Player)
end)
i seem to have an issue with teleporting a player, i’ve used a local script and normal script but it still doesnt work. When i use a normal script it always returns the “Invalid player to teleport.” error.
Okay I think what is wrong. Firstly this script as a server script won’t run properly because LocalPlayer property for the server is always nil. Secondly this script won’t run as a local script because it’s parented to a part and the part is a descendant of workspace. To fix the issue mentioned as the second problem make this a local script and move it to StarterCharacterScripts for example (if You decide to fix it like that you should also change pp variable.declaration). Also the second parameter of tpservice:Teleport() is LocalPlayer by default if this is a local script. In other words if you make it a local script, you won’t have to provide player parameter.
What you can do is use a remote event fired from the server to the client, and then teleport the player from the client. You can also do game.Players.PlayerAdded:Connect(function(plr) this will get the localplayer