Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

where would i put exacution wait time?

Asked by 4 years ago

please tell me if either my wait is to low or if i need to add another! thx

01local rightval = workspace.Part.value1.Value
02local leftval = workspace.Part.Value2.Value
03local father = script.Parent
04local pos = father.Position
05while true do
06    if pos == Vector3.new(rightval) then do
07        repeat pos = pos + Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(leftval)
08        wait (1)
09        end
10    if pos == Vector3.new(leftval) then do
11            repeat pos = pos - Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(rightval)
12            wait(1)
13            end
14        end
15    end
16end

1 answer

Log in to vote
0
Answered by 4 years ago

I figured it out! In the future click the error and on the line, the error was on add a wait before that line i had to change:

01local rightval = workspace.Part.value1.Value
02local leftval = workspace.Part.Value2.Value
03local father = script.Parent
04local pos = father.Position
05while true do
06    if pos == Vector3.new(rightval) then do
07        repeat pos = pos + Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(leftval)
08        wait (1)
09        end
10    if pos == Vector3.new(leftval) then do
11            repeat pos = pos - Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(rightval)
12            wait(1)
13            end
14        end
15    end
16end

to:

01local rightval = workspace.Part.value1.Value
02local leftval = workspace.Part.Value2.Value
03local father = script.Parent
04local pos = father.Position
05while true do
06    wait(1)--the error was on this line because there was no wait--
07    if pos == Vector3.new(rightval) then do
08        repeat pos = pos + Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(leftval)
09        wait (1)
10        end
11    if pos == Vector3.new(leftval) then do
12            repeat pos = pos - Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(rightval)
13            end
14        end
15    end
16end

so I moved the wait from the end to the beginning having the same effect with no errors the script doesn't work though

Ad

Answer this question