I am basically making an update log that has SurfaceGui's and you'll have to click a button, causing the part to move up from the ground into view. If more information is needed, Comment please.
Regular Script:
OpenedOrClosed = game.Workspace.UpdateLog["Open/Closed"].Value bool = true --213, 169.4, 62 --213, 180.4, 62 script.Parent.MouseButton1Click:connect(function() if OpenedOrClosed == "Closed" then local Updatelog = game.Workspace.UpdateLog while bool == true do Updatelog.CFrame = Updatelog.CFrame * CFrame.new(0,0.1,0) wait(0.01) if Updatelog.CFrame == CFrame.new(213, 180.4, 62) then bool = false OpenedOrClosed = "Opened" end end end if OpenedOrClosed == "Opened" then local Updatelog = game.Workspace.UpdateLog while bool == false do Updatelog.CFrame = Updatelog.CFrame * CFrame.new(0,-0.1,0) wait(0.01) if Updatelog.CFrame == CFrame.new(213, 169.4, 62) then bool = true OpenedOrClosed = "Closed" end end end end)
Your code indentation is erroneous and hence it is harder to observe that you have mismatched end
s.
I don't understand why, on line 12, you return
if the condition is true. I don't think you meant to type that, but rather:
if Updatelog.CFrame == CFrame.new(213, 180.4, 62) then bool = false OpenedOrClosed = "Opened" end
It's difficult to understand what a lot of your code is supposed to do. At the moment, it continually loops because (I'm guessing) in the second loop, the condition "bool == false" is never reached.
It may be that you only want to trigger the Opened/Closed behaviour separately, in which case you can use an elseif
check (on line 18) rather than plain if
; that way, when the user clicks, only the code for 'Opened' or 'Closed' will be triggered, but not both.
Another minor point is that, when dealing with boolean values in conditions, someVariable == true
is the same as writing someVariable
and `someVariable == false' is the same as writing 'not someVariable'. So, for example, your while loop on line 9 could be written:
while bool do --code end
ends
and will help others be able to read your code easier. if
or elseif
Just Saying but i think it does not like the line
while bool == true do
Because it mite think that your saying while true do
while true do loops stuff.