generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Two way teleporter

Previous Thread :: Next Thread 
alliancer is not online. alliancer
Joined: 18 Mar 2013
Total Posts: 1016
19 Oct 2014 01:34 PM
I just need a script I can put in a model with 2 bricks that allows you to teleport in between them, can I have some help?
Report Abuse
Reqkt is not online. Reqkt
Joined: 17 Jun 2014
Total Posts: 210
19 Oct 2014 01:48 PM
Yeah.

otherTeleporter = part


onTouch
if hit.Parent is a Player Character then
hit.Parent MoveTo otherTeleporter.Position
end end
Report Abuse
alliancer is not online. alliancer
Joined: 18 Mar 2013
Total Posts: 1016
19 Oct 2014 01:53 PM
That helps with the concept, I need to know the actual code that can execute this

This is the concept, but there are some parts that I don't know the code to do:

A = script.Parent.A
B = script.Parent.B


script.Parent.A.OnTouch:connect(function(A_)
if hit.Parent is a Player Character then
hit.Parent MoveTo B.Position
ff = Instance.new("ForceField",hit.Parent)
wait(2)
ff:Remove()
end
end)

script.Parent.B.OnTouch:connect(function(B_)
if hit.Parent is a Player Character then
hit.Parent MoveTo A.Position
ff = Instance.new("ForceField",hit.Parent)
wait(2)
ff:Remove()
end
end)
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
19 Oct 2014 01:56 PM
Use the Touched event (http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched) to get the part that touched the brick.

Use the GetPlayerFromCharacter method of game.Players or check for a Humanoid inside the part's Parent to make sure a player touched the part. This is just like a kill brick.

Use the MoveTo method of the player's character (i.e. the part's Parent) to move the player to the other part.

Here's a bit of almost code:

http://codepad.org/JUhlc0sf

Now, I suggest you add a debounce. Do some research, see if you can figure it out!

~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~
Report Abuse
Reqkt is not online. Reqkt
Joined: 17 Jun 2014
Total Posts: 210
19 Oct 2014 02:00 PM
In theory, this should work.


for _, v in pairs(script.Parent:GetChildren()) do
if (v:IsA('Part')) then
v.Touched:connect(function(hit)
if (game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)) then
if (v.Name == 'A') then
hit.Parent:MoveTo(script.Parent.B.Position)
else
hit.Parent:MoveTo(script.Parent.A.Position)
end end end) end end
Report Abuse
Reqkt is not online. Reqkt
Joined: 17 Jun 2014
Total Posts: 210
19 Oct 2014 02:01 PM
oyea, forgot a debounce.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image