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

I need help with indexing the player that clicks a button?

local TeleportService = game:GetService("TeleportService")
local gameID = 1276220417
 
function onTouched()
    local player = Clicked.Parent
        TeleportService:Teleport(gameID, player)
end

 
script.Parent.MouseButton1Click:connect(onTouched)

the local player doesnt work on it, any ideas?

1 comment

0

Also what is Clicked? That is never defined so you must of had an error for being nil

2 answers

To reference the local player you do this

local player = game.Players.LocalPlayer

2 comments

1

Clicked was never created in the script, so in return you will get a nil value.

0

thx for the help, it isnt the player that messes up the script, idk what it is, thx for your time

I’m not completely sure about this but I think you have to set a variable for the player using local player instead of clicked.Parent but when you are using the variable for teleporting put .UserId after it.

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