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

Anyway to to fix this "Workspace.Part.Script:6: 'end' expected (to close 'for' at line 3) "?

Asked by 9 years ago

I didn't want to use while true do in the script,so I used repeat but I got a error in the output. If I move the repeat to line 5 I won't get a error but it won't work.

Error:

workspace.Part.Script:6: 'end' expected (to close 'for' at line 3) near 'until'

repeat
Part = script.Parent
for Number,Player in pairs (game.Players:GetChildren()) do --Gets the name of all Players
    print(Player)
    Distance = (Player.Character.Torso.Position - Part.Position).magnitude -- Subtracts the Player's torso with Position of the part
    until Distance < 6
    if Distance < 6 --If the distance is less then 6 then it will print that your close to the part
        then print("Your close to",Part.Name,"the total distance is "..Distance)
    else
        print("Not even close to",Part.Name,"The total distance is "..Distance)

    end
end

Changed line 5 and put repeat below

No error but doesn't work.

Part = script.Parent
for Number,Player in pairs (game.Players:GetChildren()) do --Gets the name of all Players
    print(Player)
    Distance = (Player.Character.Torso.Position - Part.Position).magnitude -- Subtracts the Player's torso with Position of the part
repeat
    until Distance < 6
    if Distance < 6 --If the distance is less then 6 then it will print that your close to the part
        then print("Your close to",Part.Name,"the total distance is "..Distance)
    else
        print("Not even close to",Part.Name,"The total distance is "..Distance)

    end
end

Answer this question