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

Whats wrong with my loading bar script? [closed]

Asked by 9 years ago

The output says,"Workspace.Starting Functions.Script:3: '(' expected near '='"

LoadBar = game.StarterGui.LoadingScreen.FrameMain.Bar.AbsoluteSize
function
LoadBar = "154,0"
wait(2)
LoadBar = "340,0"
wait(1)
LoadBar = "677,0"
wait(1)
LoadBar = "964,0"
wait(5)
LoadBar = "1000,0"
wait(3)
LoadBar = "1473,0"
end



0
This isn't even close to right. Almost every detail has a mistake. BlueTaslem 18071 — 9y
0
Could you possibly correct it? Just telling me I am wrong wouldn't help. Thanks for the feedback though. kingstephen23 35 — 9y

Locked by User#5978 and Perci1

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Syntax

Your error is a syntax error -- what you've written doesn't mean anything because it doesn't make sense to the computer.

It's telling you that it expects ( near = on line 3. In other words, it expected something like

function LoadBar(

but you gave it

function LoadBar = 

That isn't valid Lua. Function definitions (normally) need to have names:

LoadBar = game.StarterGui.LoadingScreen.FrameMain.Bar.AbsoluteSize
function moveLoadingBar()
    LoadBar = "154,0"
    wait(2)
    LoadBar = "340,0"
    wait(1)
    LoadBar = "677,0"
    wait(1)
    LoadBar = "964,0"
    wait(5)
    LoadBar = "1000,0"
    wait(3)
    LoadBar = "1473,0"
end

You don't call this function, so it will never happen. There's not really even a point to the function in that case.

Read Only

AbsoluteSize is read only:

This property can only be read from. Attempting to write to it will cause an error.

If you want to change the size, change the .Size property.

Types

Size (or AbsoluteSize for that matter) is not text. "340,0" does not describe a size, it describes a chunk of text.

You need to make the object of the right type. You can check what type is needed in the Wiki or Object browser.

For example,

[AbsoluteSize] Value Type: Vector2

\

[Size] Value Type: UDim2

If you click the link UDim2 you can see the list of constructors -- how to construct a UDim2.

You want UDim2.new(0, 340, 0, 0).

Assignments

When you define LoadBar in the first line, that just sets LoadBar to the current AbsoluteSize.

It does not "link" LoadBar to the absolute size of loadbar.

If you want to change a property, you have to do it explicitly.

local bar = game.StarterGui.LoadingScreen.FrameMain.Bar

bar.Size = UDim2.new(0, 154, 0, 0)
wait(2)
bar.Size = UDim2.new(0, 340, 0, 0)
wait(1)
....
Ad