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

Why can't I view any of these items in ServerStorage?

Asked by 5 years ago

What the script is suppose to do.

It is suppose to print the list of items in the scrollframe while changing the name of the Label to what that section is suppose to be.

This does work but not in ServerStorage.

I know what ServerStorage is and that's why I'm trying to get this to work.

The Script itself

--Made By MillerrIAm
--------------Variables------------
Music = game:GetService("ServerStorage").MusicFolder:GetChildren()
SFrame = script.Parent.ScrollingFrame
Value = 0
Number = 0
-------------Main Script------------
while script.Disabled == false do
    for i,v in pairs(Music) do
        if Value == 0 then
            frame = SFrame.MusicFrame:Clone()
            frame.Visible = true
            frame.Parent = SFrame
            frame.Position = frame.Position + UDim2.new(0,0,0,Number)
            frame.Label.Text = v.Name
            Value = 1
        elseif Value == 1 then
            frame = SFrame.MusicFrame:Clone()
            frame.Visible = true
            frame.Parent = SFrame
            frame.Position = frame.Position + UDim2.new(0.5,0,0,Number)
            frame.Label.Text = v.Name
            Value = 0
            Number = Number + 50
        end
    end
    script.Disabled = true
end

Thank you for any help you give!

1
Is this a local script? A local script can't access ServerStorage since it runs on the client. Jexpler 63 — 5y
0
Local Script Just2Terrify 566 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

ServerStorage. Think of it for a moment.

The contents of ServerStorage are accessible only to the server and not to clients. What you should do is move the music folder to ReplicatedStorage, whose contents are available to the server AND client.

Don't disable the script itself, if you have to do this you're doing something wrong. Instead use a variable that will act like a flag.

local flag = true

while flag do -- Notice no == true or == false.
    -- ... 
    flag = false -- Shouldn't run anymore
end

Notice no == true or == false. If you need to test if it's falsey, invert it with not.

Also pls use local variables, globales are bad practice. With a local variable, it is easier to see when the variable is being declared first-time, and accessing local variables is only slightly, pretty much negligible, faster than global variables.

0
Alright, that makes a lot more sense then what I was doing. Thank you! Just2Terrify 566 — 5y
Ad

Answer this question