Hello! I am WEcompany who is working on my next game. What I want to know is how would I be able to Wait for 2 different object values before doing these specific function
local Car = script.Parent
wait(25)
while true do
wait(30)
for i = 1,930 do
Car:TranslateBy(Vector3.new(0,-0.03,0))
wait()
end
for i = 1,930 do
Car:TranslateBy(Vector3.new(-0,0.03,0))
wait()
end
end
local door = script.Parent
wait(25)
while true do
door.Transparency = 1
door.CanCollide = false
wait(30)
door.Transparency = 0
door.CanCollide = true
wait(61.89)
end
I just want to finish the elevators so we can work on the next thing.
If you can help, please respond. Thanks!
If you need more information, please let me know.
If you’re waiting for objects with specific players’ names to be inserted, you should use WaitForChild like Dark mentioned.
If you’re waiting for a certain number of player values to exist in that folder, you could use a loop with local num = #TeleportPoint.Players:GetChildren(), or use ChildAdded and keep track of it that way.
Adding onto what @sean21307 said,
If you are awaiting a certain amount of players, you could easily make a repeat wait() until num >= required loop for it, where required would be any amount you desire or see if specified people are listed by making checks inside of the loop and then ending the loop by seeing if the check is true.
Generally if objects can come and go, I’d use FindFirstChild(), eg:
while true do
local one = foo:FindFirstChild( desiredName1 )
local two = foo:FindFirstChild( desiredName2 )
if one and two then
if one.Whatever == desired1whatever and two.Whatever == desired2whatever then
-- Do whatever here (Both objects and values exist.)
break
end
end
-- Yield here
end
Well then you can use GetChildren() as mentioned earlier and iterate through the children, and if you have two, go from there.
Edit:
I’m assuming you have the ‘elevator’ players in a table, or Values parented to an object already somewhere.
Or are you asking how to initially select two random players?
But now the doors arent opening.
Here is what im doing:
local door = script.Parent
local TeleportPoint = script.Parent.Parent.TeleportPoint
wait()
while true do
door.Transparency = 1
door.CanCollide = false
repeat
wait()
until #TeleportPoint.Players:GetChildren() >= 2
door.Transparency = 0
door.CanCollide = true
wait(61.89)
end
local Car = script.Parent
local TeleportPoint = script.Parent.Parent.TeleportPoint
wait()
while true do
repeat
wait()
until #TeleportPoint.Players:GetChildren() >= 2
for i = 1,930 do
Car:TranslateBy(Vector3.new(0,-0.03,0))
wait()
end
for i = 1,930 do
Car:TranslateBy(Vector3.new(-0,0.03,0))
wait()
end
end
You don’t need to do TeleportPoint.Players if the variable is already that, and I don’t think you meant to have the repeat loop in the while loop.
local door = script.Parent
local TeleportPoint = script.Parent.Parent.TeleportPoint.Players
wait()
repeat
wait()
until #TeleportPoint.Players:GetChildren() >= 2
while true do
door.Transparency = 1
door.CanCollide = false
door.Transparency = 0
door.CanCollide = true
wait(61.89)
end
local Car = script.Parent
local TeleportPoint = script.Parent.Parent.TeleportPoint
wait()
repeat
wait()
until #TeleportPoint.Players:GetChildren() >= 2
while true do
for i = 1,930 do
Car:TranslateBy(Vector3.new(0,-0.03,0))
wait()
end
for i = 1,930 do
Car:TranslateBy(Vector3.new(-0,0.03,0))
wait()
end
end