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 3 years ago

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

local rightval = workspace.Part.value1.Value
local leftval = workspace.Part.Value2.Value
local father = script.Parent
local pos = father.Position
while true do
    if pos == Vector3.new(rightval) then do
        repeat pos = pos + Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(leftval)
        wait (1)
        end
    if pos == Vector3.new(leftval) then do 
            repeat pos = pos - Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(rightval)
            wait(1)
            end
        end
    end
end

1 answer

Log in to vote
0
Answered by 3 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:

    local rightval = workspace.Part.value1.Value
    local leftval = workspace.Part.Value2.Value
    local father = script.Parent
    local pos = father.Position
    while true do
        if pos == Vector3.new(rightval) then do
            repeat pos = pos + Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(leftval)
            wait (1)
            end
        if pos == Vector3.new(leftval) then do
                repeat pos = pos - Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(rightval)
                wait(1)
                end
            end
        end
    end

to:

local rightval = workspace.Part.value1.Value
local leftval = workspace.Part.Value2.Value
local father = script.Parent
local pos = father.Position
while true do
    wait(1)--the error was on this line because there was no wait--
    if pos == Vector3.new(rightval) then do
        repeat pos = pos + Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(leftval)
        wait (1)
        end
    if pos == Vector3.new(leftval) then do 
            repeat pos = pos - Vector3.new(1,0,0) and wait(1) until pos == Vector3.new(rightval)
            end
        end
    end
end

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