Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 4 years ago
script.Parent.MouseButton1Click:connect(function()
    local player = game.Players.LocalPlayer

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

It says invalid player to teleport

0
Is it LocalScript? Block_manvn 395 — 4y
0
Yes DeadStroke509 3 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

Answer this question