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

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

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

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)

2 comments

0

I still get an error saying that MouseClick is not a valid member of part.

0

Insert a ClickDetector inside the part and put the script in the part.

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