Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 05:43 PM |
I 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 |
|
|
Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 05:49 PM |
?
ʰᵉʸ ʷʰᵒ ᵐᵃᵈᵉ ᵐʸ ᵏᵉʸᵇᵒᵃʳᵈ ᵗᶦⁿʸ|R$99,788|~Rocks Owner & Lead VC'er|+2.3k posts |
|
|
| Report Abuse |
|
|
V_PN
|
  |
| Joined: 08 May 2011 |
| Total Posts: 121 |
|
|
| 02 Dec 2017 05:55 PM |
I'd something like add two string values and then use them to depend on if two players have clicked it.
Then it'd save the persons name (when the button is clicked) in the first value SPECIFICALLY, and to prevent it from overwriting in the next step make sure the value isnt nil or something.
Then if the first value isn't nil then it'd go to the second one where it would store it, then after that get the two players and teleport them to their location.
After that replace the values back to nil.
Might work, might not.
#code print('0') |
|
|
| Report Abuse |
|
|
LuaCymru
|
  |
| Joined: 22 Jan 2015 |
| Total Posts: 394 |
|
|
| 02 Dec 2017 06:21 PM |
local telebrick = script.Parent local position = Vector3.new(0,50,0) --replace the coordinates with the actual destination coordinates local Detector = Instance.new("ClickDetector") local bool = Instance.new('BoolValue',telebrick) bool.Value =0 other = '' Detector.Parent = telebrick
telebrick.ClickDetector.MouseClick:connect(function(plr) if bool.Value == false then other = plr.Name bool.Value = true else if game.Players:FindFirstChild(other) then plr2 = game.Players:FindFirstChild(other) plr1 = plr plr1.Character:MoveTo(position) plr2.Character:MoveTo(position) bool.Value = false other = '' else other = plr.Name bool.Value = true end end end) |
|
|
| Report Abuse |
|
|
LuaCymru
|
  |
| Joined: 22 Jan 2015 |
| Total Posts: 394 |
|
|
| 02 Dec 2017 06:22 PM |
local telebrick = script.Parent local position = Vector3.new(0,50,0) --replace the coordinates with the actual destination coordinates local Detector = Instance.new("ClickDetector") local bool = Instance.new('BoolValue',telebrick) bool.Value =false other = '' Detector.Parent = telebrick
telebrick.ClickDetector.MouseClick:connect(function(plr) if bool.Value == false then other = plr.Name bool.Value = true else if game.Players:FindFirstChild(other) then plr2 = game.Players:FindFirstChild(other) plr1 = plr plr1.Character:MoveTo(position) plr2.Character:MoveTo(position) bool.Value = false other = '' else other = plr.Name bool.Value = true end end end) |
|
|
| Report Abuse |
|
|
Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 06:24 PM |
Thats script can fire if the same person clicks it twice
ʰᵉʸ ʷʰᵒ ᵐᵃᵈᵉ ᵐʸ ᵏᵉʸᵇᵒᵃʳᵈ ᵗᶦⁿʸ|R$99,788|~Rocks Owner & Lead VC'er|+2.3k posts |
|
|
| Report Abuse |
|
|
V_PN
|
  |
| Joined: 08 May 2011 |
| Total Posts: 121 |
|
|
| 02 Dec 2017 06:26 PM |
Then do something like the second value isn't the same as one. ez
#code while true do end |
|
|
| Report Abuse |
|
|
Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 06:39 PM |
how?
ʰᵉʸ ʷʰᵒ ᵐᵃᵈᵉ ᵐʸ ᵏᵉʸᵇᵒᵃʳᵈ ᵗᶦⁿʸ|R$99,788|~Rocks Owner & Lead VC'er|+2.3k posts |
|
|
| Report Abuse |
|
|
Barmoi
|
  |
| Joined: 21 Jun 2011 |
| Total Posts: 3797 |
|
|
| 02 Dec 2017 06:51 PM |
DSFSF
ʰᵉʸ ʷʰᵒ ᵐᵃᵈᵉ ᵐʸ ᵏᵉʸᵇᵒᵃʳᵈ ᵗᶦⁿʸ|R$99,788|~Rocks Owner & Lead VC'er|+2.3k posts |
|
|
| Report Abuse |
|
|