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

Making a Clickable brick that teleports you to another game?

Asked by 5 years ago

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

1 answer

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
5 years ago

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)

0
Oh, wow thank you! panichub 29 — 5y
0
Wait it still doesn't work panichub 29 — 5y
0
I fixed it, I also didn't need to clarify ClickDetector twice since the scripts parent is the ClickDetector panichub 29 — 5y
Ad

Answer this question