|
| 16 Sep 2016 08:13 PM |
I am trying to create an elevator where when a player touches the floor of the elevator then they get added to a table. Then any player's characters inside the elevator go up with the elevator. But when two players are in the elevator only one person goes up and the other stays at the bottom. Can anyone tell me what I have done wrong? Here is my script:
local names={}
script.Parent.Floor.Touched:connect(function(hit) local plr=game.Players:GetPlayerFromCharacter(hit.Parent) if plr then if not names[plr.Name] then names[plr.Name]=true end end end)
debounce=true
script.Parent.ElevatorControl.ClickDetector.mouseClick:connect(function() for k,v in pairs(game.Players:GetChildren()) do if names[v.Name] and debounce then script.Parent.Door1.Transparency=0.5 script.Parent.Door1.CanCollide=true script.Parent.Door2.Transparency=0.5 script.Parent.Door2.CanCollide=true local i=1 while wait() do if i>=3 then print(i) script.Parent.Door1.Transparency=100 script.Parent.Door1.CanCollide=false script.Parent.Door2.Transparency=100 script.Parent.Door2.CanCollide=false break end v.Character.Torso.CFrame=v.Character.Torso.CFrame+Vector3.new(0,i,0) script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame+Vector3.new(0,i,0)) i=i+0.1 end debounce=false end end end)
script.Parent.ElevatorControl2.ClickDetector.mouseClick:connect(function() for x,z in pairs(game.Players:GetChildren()) do if names[z.Name] and not debounce then script.Parent.Door1.Transparency=0.5 script.Parent.Door1.CanCollide=true script.Parent.Door2.Transparency=0.5 script.Parent.Door2.CanCollide=true local i=1 while wait() do print(i) if i>=3 then script.Parent.Door1.Transparency=100 script.Parent.Door1.CanCollide=false script.Parent.Door2.Transparency=100 script.Parent.Door2.CanCollide=false break end z.Character.Torso.CFrame=z.Character.Torso.CFrame-Vector3.new(0,i,0) script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame-Vector3.new(0,i,0)) i=i+0.1 end debounce=true end end end) |
|
|
| Report Abuse |
|
| |
|
| 16 Sep 2016 08:25 PM |
| You have your waits inside the loop that check for the player. |
|
|
| Report Abuse |
|
| |