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

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

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"))

2 comments

1

Does it teleport the player when they load in? Please describe your answer more clearly. I also recommend a local script 

1

Remove the parenthesis after the OnClick on line 10

1 answer

✓ Accepted answer

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!

2 comments

1

THIS IS A LOCAL SCRIPT

0

Thanks

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