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

Im making a teleport button but it says invalid player to teleport??

script.Parent.MouseButton1Click:connect(function()
    local player = game.Players.LocalPlayer

game:GetService("TeleportService"):Teleport(4931146666, player)
end)

It says invalid player to teleport

2 comments

0

Is it LocalScript?

0

Yes

3 answers

I don't know much about teleport service, but I would try replacing local player = blah blah bah with

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

See if that works.

You cannot teleport through a client sided localscript. I recommend using remote events.

server script, no local!

local TeleportService = game:GetService("TeleportService")
local cd = game.workspace.blabla -- your clickdetector's location
local place2 = 000000000  --your place Id

cd.MouseClick:connect(function(playerclicked)

TeleportService:Teleport(place2, playerclicked)

end

if that did'nt work i suggest...


local TeleportService = game:GetService("TeleportService")


local place2 = 000000000 -- your place ID

local teleTo = game.Workspace. -- the to touch part

local function onPartTouch(otherPart)
	
	local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
		if player then
			TeleportService:Teleport(place2, player)
		end
	
end

teleTo.Touched:Connect(onPartTouch)

try using a to touch part

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