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

is it possible to create a teleport pad using "instance.new()" inside a tool?

Asked by
Annon28 23
6 years ago
Edited 6 years ago

so i planning to make a "Rick and Morty" portal gun that allow me to create a "Teleport pad" that will make me to teleport to another game if i click the portal. so i wrote this scripts on the tool i made


portal = false function clicked() if portal == false then portal = true local wormhole = Instance.new("Part") wormhole.Anchored = true wormhole.Parent = workspace wormhole.Name = "Hole" wormhole.Size = Vector3.new(5, 5, 1) wormhole.BrickColor = BrickColor.new("Lime green") wormhole.CFrame = script.Parent.Handle.CFrame local enter = Instance.new("ClickDetector") enter.Parent = game.Workspace.Hole wait(5) game.Workspace.Hole:remove() portal = false end end script.Parent.Activated:connect(clicked) function tp(player) if portal == true then game:GetService("TeleportService"):Teleport(938093581,player) end end game.Workspace.Hole.ClickDetector.MouseClick:connect(tp)

so it create a portal but i cant teleport to the place that i want to visit. is something wrong with my script?.

0
Does the worm hole get created? RevergeHelps 63 — 6y
0
yes but it cant teleport me to other place/game Annon28 23 — 6y
0
Did my script work? RevergeHelps 63 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
portal = false

function clicked()
    if portal == false then
    portal = true
    local wormhole = Instance.new("Part")
    wormhole.Anchored = true
    wormhole.Parent = workspace
    wormhole.Name = "Hole"
    wormhole.Size = Vector3.new(5, 5, 1)
    wormhole.BrickColor = BrickColor.new("Lime green")
    wormhole.CFrame = script.Parent.Handle.CFrame
    local enter = Instance.new("ClickDetector")
    enter.Parent = game.Workspace.Hole

    enter.MouseClick:connect(function(player)
    if portal == true then
    game:GetService("TeleportService"):Teleport(938093581,player)
    end
    end)

    wait(5)
    game.Workspace.Hole:destroy()
end

script.Parent.Activated:connect(clicked)
0
:Destroy() not :destroy() PyccknnXakep 1225 — 6y
0
and :Connect() not :connect() PyccknnXakep 1225 — 6y
0
I used his code, just moved it around. Also, I'm inside of in school suspension right now so I have no access to studio. RevergeHelps 63 — 6y
1
bad bad boy creeperhunter76 554 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Now here's one thing you need to know. You cannot write a script inside of another script

It will be much better to simply create a portal and add an "on touch" teleportation script to it instead. Then place it in ReplicatedStorage and clone it with your script instead of creating a new instance. Finally, assigning the parent of the script to the workspace and positioned (and rotated) in front of you.

Now as for TeleportService, I am not familiar with that concept as it is new to me. It could work but I dont know how, I'm more familiar with moving the CFrame of the PrimaryPart of the Character to somewhere else, that kind of teleportation.

Either way, I hope this helps a bit at least

Answer this question