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

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

Asked by 7 years ago
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?

0
Also what is Clicked? That is never defined so you must of had an error for being nil Impacthills 223 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago

To reference the local player you do this

local player = game.Players.LocalPlayer
1
Clicked was never created in the script, so in return you will get a nil value. marioman66 1 — 7y
0
thx for the help, it isnt the player that messes up the script, idk what it is, thx for your time JakePlays_TV 97 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.

Answer this question