Hi, I'm currently working on a teleport button that teleports you to another game when you click it instead of stepping over it. I went off with the onTouch first, to see how it works and it does. But, when I try to make a click function of it, it doesn't work at all.
I put the click detector in a part, and then a script in the part. and the part is in workspace.
local TeleportService = game:GetService("TeleportService") local placeID_1 = 4505065903 local placeID_2 = 4483453486 script.Parent.ClickDetector.MouseClick:Connect(function() local player = game.Players:GetPlayerFromCharacter(script.Player) if player then TeleportService:Teleport(placeID_1, player) end end)
I didn't know exactly what to put in where it says "script.Player" so can I get help on that too?? Image here: https://gyazo.com/6865b0516ac27265ad2f02cf1bceada2
ClickDetectors will always have a parameter of the player who clicked. So there is no need to use GetPlayerFromCharacter whatsoever.
local TeleportService = game:GetService("TeleportService") local placeID_1 = 4505065903 local placeID_2 = 4483453486 script.Parent.ClickDetector.MouseClick:Connect(function(player) TeleportService:Teleport(placeID_1, player) end)