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 4 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 — 4y
1
Remove the parenthesis after the OnClick on line 10 kisty1 111 — 4y

1 answer

Log in to vote
1
Answered by
BashGuy10 384 Moderation Voter
4 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 — 4y
0
Thanks AndriusTheGreat 140 — 4y
Ad

Answer this question