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

How can I make a ClickDetector that teleports LocalPlayer to another Place?

I've tried everything I know, and it never works, it works when I teleport myself using Script, but LocalPlayer dosen't work on Scripts (the script below is in LocalScript)

function onClick()
	game:GetService("TeleportService"):Teleport(2208185784)
end

script.Parent.Parent.ClickDetector.MouseClick:Connect(onClick)

1 comment

1 answer

✓ Accepted answer

###LocalScripts cannot run in Workspace. An exception would be if its parent is the player's character. LocalScripts only run under the following:

  • PlayerGui
  • Backpack
  • PlayerScripts
  • Player's Character
  • ReplicatedFirst service

###A fix would be to switch to a Script.

local function onClick(player) -- player passed by MouseClick, and use local functions
    game:GetService("TeleportService"):Teleport(2208185784, player)
    -- player to teleport as an argument
end

script.Parent.Parent.ClickDetector.MouseClick:Connect(onClick)

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