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

moving brick in a while true do script?

Asked by 5 years ago

So I have this script,

local count = script.Parent.Height.Value
wait(3)
while true do
    if count < 7.5 then
        script.Parent.CFrame=script.Parent.CFrame+Vector3.new(0,0.1,0)
        count = count + 0.1
        wait(0.1)
    else
            if count >= 7.5 then
        script.Parent.CFrame=script.Parent.CFrame+Vector3.new(0,-7.5,0)
        count = 7.5
    end

but it doesnt work at the top line 'count' is a number value under the same group as the brick(the scripts parent)

the 'end' on the bottom line is underlined in red and says "expected 'end' (to close 'else' at line nine), got <eof>

I dont understand whats wrong? the idea is that the scripts parent gets raised in increases of .1 every 0.1 seconds until the height reaces 7.5 in which case it should lower the part by 7.5 studs and continue the proccess

2 answers

Log in to vote
1
Answered by 5 years ago

You were missing an "end". That's the error you got. The while loop needs an end to determine where the loop stops. Also don't put .Value in a variable, I corrected that in the code.

local count = script.Parent.Height
wait(3)
while true do
    if count.Value < 7.5 then
        script.Parent.CFrame=script.Parent.CFrame+Vector3.new(0,0.1,0)
        count = count + 0.1
        wait(0.1)
    else
            if count.Value >= 7.5 then
        script.Parent.CFrame=script.Parent.CFrame+Vector3.new(0,-7.5,0)
        count = 7.5
    end
end
0
thx alot barrettr500 53 — 5y
Ad
Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

You forgot to put end after line 12 and dont use .Value in variables.

Here is the fixed script:

local count = script.Parent.Height
wait(3)
while true do
    if count.Value < 7.5 then
        script.Parent.CFrame=script.Parent.CFrame+Vector3.new(0,0.1,0)
        count.Value = count.Value + 0.1
        wait(0.1)
    else
            if count.Value >= 7.5 then
        script.Parent.CFrame=script.Parent.CFrame+Vector3.new(0,-7.5,0)
        count.Value = 7.5
    end
end

Hope it helped :)

0
i beat u :p DinozCreates 1070 — 5y
0
lmao, I did not analyze right, I just ran to answer xD yHasteeD 1819 — 5y
0
you're tryna steal all that easy rep, dw if he gives me answer ill +rep yours lol DinozCreates 1070 — 5y
0
I'm trying to get back active here, but I do not have much free time :v yHasteeD 1819 — 5y

Answer this question