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

Why does it teleport before the player has clicked the button?

Asked by 5 years ago

Why does it teleport before the player has clicked the button?

local TeleportService = game:GetService("TeleportService")
local placeID_1 = 3792830514
local player = game.Players.LocalPlayer

local function OnClick(Val)
    print(Val)
    TeleportService:Teleport(placeID_1, player)
end

script.Parent.Activated:Connect(OnClick("Clicked"))

1
Does it teleport the player when they load in? Please describe your answer more clearly. I also recommend a local script  BashGuy10 384 — 5y
1
Remove the parenthesis after the OnClick on line 10 kisty1 111 — 5y

1 answer

Log in to vote
1
Answered by
BashGuy10 384 Moderation Voter
5 years ago

Maybe try this?

local TeleportService = game:GetService("TeleportService")
local placeId = 0 -- replace here

-- teleport the user
script.Parent.Activated:Connect(function()
    TeleportService:Teleport(placeId)
end)

This should work, mark this as the answer if it worked!

1
THIS IS A LOCAL SCRIPT BashGuy10 384 — 5y
0
Thanks AndriusTheGreat 140 — 5y
Ad

Answer this question