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

How would I loop this 'smashing' brick script?

Asked by 7 years ago
local brick = script.Parent
for i = 1,15 do
brick.CFrame  = brick.CFrame*CFrame.new(0,-1.2,0)
wait(.1)

end

wait(2)

local brick = script.Parent
for i = 1,15 do
brick.CFrame  = brick.CFrame*CFrame.new(0,1.2,0)
wait(.1)

end

This basically, successfully, makes the brick smash down into the floor and come back up. Though, I can't seem to loop it. When I use the while true do line, it refuses to work. Output when I put it:

*23:14:58.966 - Workspace.Thumper.Script:17: 'end' expected (to close 'while' at line 1) near '<eof>'

Anyone know how I could fix this? Yes, I'm still beginning with the CFrame stuff.

0
Did you gave us the full script? it seems like you didnt close the loop.. personal_ly 151 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago
while true do
    local brick = script.Parent

    for i = 1,15 do
        brick.CFrame  = brick.CFrame*CFrame.new(0,-1.2,0)
        wait(.1)
    end
end

Everything is good here just need to add the "while true do", so it will loop through your code. The that you received error basically says that an "end keyword" needs to be placed on line 17 to complete the loop that you started on line 1. Remember that loops and if statements need to be completed by typing the "end" keyword after them.

Also I would probably set the position of the brick rather than multiplying and setting the CFrame, because you would have the same effect, and it's more efficient.

Ad

Answer this question