Why does it teleport before the player has clicked the button?
01 | local TeleportService = game:GetService( "TeleportService" ) |
02 | local placeID_ 1 = 3792830514 |
03 | local player = game.Players.LocalPlayer |
04 |
05 | local function OnClick(Val) |
06 | print (Val) |
07 | TeleportService:Teleport(placeID_ 1 , player) |
08 | end |
09 |
10 | script.Parent.Activated:Connect(OnClick( "Clicked" )) |
Maybe try this?
1 | local TeleportService = game:GetService( "TeleportService" ) |
2 | local placeId = 0 -- replace here |
3 |
4 | -- teleport the user |
5 | script.Parent.Activated:Connect( function () |
6 | TeleportService:Teleport(placeId) |
7 | end ) |
This should work, mark this as the answer if it worked!