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

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

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?.

3 comments

0

Does the worm hole get created?

0

yes but it cant teleport me to other place/game

0

Did my script work?

2 answers

✓ Accepted answer
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)

4 comments

0

:Destroy() not :destroy()

0

and :Connect() not :connect()

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.

1

bad bad boy

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

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