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

My teleporting script is having problems..?

Asked by
IcyEvil 260 Moderation Voter
8 years ago

Alright so this question was asked before by me, and they helped me update the script an extent but it still did and does not work, so I am going to need help yet again with it.

So here is the script they gave me.

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

The script is supposed to be when you click a certain brick you get teleported to a new game(the ID is just a random number value but I have used it with an actual games ID and it did not work)

0
Is it a Server or Local Script? SimplyRekt 413 — 8y
0
It is a Server script within a part IcyEvil 260 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

MouseClick is not an event of a part. If you want to detect when a player clicks on a part, you will have to use another method. One way to do that is to use a ClickDetector object, which will allow you to do exactly this.

Workspace
    Part
        ClickDetector
        Script

Above is the hierarchy order you should have

local ClickDetector = script.Parent.ClickDetector
local mult_ID = 34534

local function PartClickedBy(Player)
    if Player ~= nil then
        game:GetService("TeleportService"):Teleport(mult_ID, Player)
    end
end

ClickDetector.MouseClick:connect(PartClickedBy)
0
Thank You! this was a needed script in my game! Thank You So Very Much! IcyEvil 260 — 8y
Ad

Answer this question