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

Why is my click-to-teleport script not working?

Asked by
IcyEvil 260 Moderation Voter
8 years ago

I probably screwed it up when trying to make an anonymous function but its crucial that it have a click detector in it as well.

here is the code..

local mult_ID = 34534
script.Parent.Clicked:connect(function(OnClick)
    local player = game.Players:GetPlayerFromCharacter(OnClick.Parent)
    if player then
        game:GetService("TeleportService"):Teleport(mult_ID, player)
    end
end)

1 answer

Log in to vote
2
Answered by 8 years ago

The mistake is on line 2.

Is this a ClickDetector, because Clicked isn't a valid member.

local mult_ID = 34534
script.Parent.MouseClick:connect(function(player)--onClick is the Player therefore...
    if player then
        game:GetService("TeleportService"):Teleport(mult_ID, player)
    end
end)
0
I still get an error saying that MouseClick is not a valid member of part. IcyEvil 260 — 8y
0
Insert a ClickDetector inside the part and put the script in the part. UniversalDreams 205 — 8y
Ad

Answer this question