Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 06:19 PM |
need help with a 2 player teleportation script. So if 2 people click a part they both teleport somewhere. I only made a script for one person, Can someone help me make it for 2 players?
Script:
local telebrick = script.Parent local position = Vector3.new(0,50,0) --replace the coordinates with the actual destination coordinates local Detector = Instance.new("ClickDetector") Detector.Parent = telebrick
telebrick.ClickDetector.MouseClick:connect(function(plr) plr.Character.HumanoidRootPart.CFrame = CFrame.new(position) end)
ʰᵉʸ ʷʰᵒ ᵐᵃᵈᵉ ᵐʸ ᵏᵉʸᵇᵒᵃʳᵈ ᵗᶦⁿʸ|R$99,788|~Rocks Owner & Lead VC'er|+2.3k posts |
|
|
| Report Abuse |
|
|
Aliics
|
  |
| Joined: 29 Sep 2014 |
| Total Posts: 471 |
|
|
| 02 Dec 2017 07:05 PM |
-- I wrote this right now -- It may not be the best and it may not even work -- But it should :)
players = {}; telebrick = script.Parent; position = Vector3.new(0, 50, 0); detector = Instance.new("ClickDetector", telebrick);
telebrick.ClickDectector.MouseClick:connect(function(_player)) if (players[1] == nil or players[2] == nil) then local _choose = players[1] == nil and 1 or 2; players[choose] = _player; if (choose == 2) then players[1].Character.HumanoidRootPart.CFrame = CFrame.new(position); players[2].Character.HumanoidRootPart.CFrame = CFrame.new(position); players[] = {}; end else players[] = {}; end end) |
|
|
| Report Abuse |
|
|
Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 07:09 PM |
The click detector does not work
ʰᵉʸ ʷʰᵒ ᵐᵃᵈᵉ ᵐʸ ᵏᵉʸᵇᵒᵃʳᵈ ᵗᶦⁿʸ|R$99,788|~Rocks Owner & Lead VC'er|+2.3k posts |
|
|
| Report Abuse |
|
|
Aliics
|
  |
| Joined: 29 Sep 2014 |
| Total Posts: 471 |
|
|
| 02 Dec 2017 07:11 PM |
-- I renamed the event to the variable -- and I removed a parentheses.
detector = Instance.new("ClickDetector", telebrick);
detector.MouseClick:connect(function(_player) |
|
|
| Report Abuse |
|
|
Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 07:13 PM |
still
ʰᵉʸ ʷʰᵒ ᵐᵃᵈᵉ ᵐʸ ᵏᵉʸᵇᵒᵃʳᵈ ᵗᶦⁿʸ|R$99,788|~Rocks Owner & Lead VC'er|+2.3k posts |
|
|
| Report Abuse |
|
|
Aliics
|
  |
| Joined: 29 Sep 2014 |
| Total Posts: 471 |
|
|
| 02 Dec 2017 07:20 PM |
-- Decided to hop into studio and get that working for you -- It is tested and working, sorry it took so long for me to get back to you :)
players = {}; telebrick = script.Parent; position = Vector3.new(0, 50, 0); detector = Instance.new("ClickDetector", telebrick);
detector.MouseClick:connect(function(_player) if (players[1] == nil or players[2] == nil) then if (players[1] == _player) then return; end local _choose = players[1] == nil and 1 or 2; players[_choose] = _player; if (_choose == 2) then players[1].Character.HumanoidRootPart.CFrame = CFrame.new(position); players[2].Character.HumanoidRootPart.CFrame = CFrame.new(position); players = {}; end else players = {}; end end) |
|
|
| Report Abuse |
|
|