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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 17 Jun 2014 |
| Total Posts: 210 |
|
| |
|