How do I make this script that only teleports 1 player?

help

It teleports everyone in game, but I only want one to be teleported when clicked.

People: Dude you literally got it from toolbox, you need to make your own code you stupid… Go die irl

No first of all I copied it from tutorial that my friend gave me when I asked her how to get script teleport and I’m currently trying to understand.

I feel like the i and the Players has something to do with making everyone teleported, But idk what to replace it from

Simply put return. That will make it run only once.

We can see that MouseClick returns the player who clicked it.
https://developer.roblox.com/en-us/api-reference/event/ClickDetector/MouseClick

local TELEPORT_POSITION = Vector3.new(0, 500, 0)

local clickDetector = script.Parent.ClickDetector

-- Called when a player clicks the click detector
local function onMouseClick(player)
    local character = player.Character
    character:MoveTo(TELEPORT_POSITION)
end

clickDetector.MouseClick:Connect(onMouseClick)
1 Like

Ahhh that makes sense, I really need to find a Roblox Lua code Book if there’s one irl but thank you so much!