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

Why is this LoadingScreen GUI not doing what I want?

Asked by 8 years ago

I was hoping on play a song while my loading screen is playing however it doesn't want to play music and I am stumped I was hoping that you guy could help me. (PS I plan on adding more things to the screen but I need to get the sound in) If it helps, I was hoping to have the loading screen displayed as long as the Song plays. Here is the script-

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)

local screen = Instance.new("ScreenGui")
screen.Parent = PlayerGui

local textLabel = Instance.new("TextLabel")
textLabel.Parent = screen
textLabel.Text = "Welcome to the City of bloxbury"
textLabel.Size = UDim2.new(1,0,1,0)
textLabel.FontSize = Enum.FontSize.Size14
textLabel.Font = Enum.Font.SourceSansLight

local sound = Instance.new.sound(334321597)
timelength = (60)

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local count = 0
local start = tick (1)
while tick(60)- start < 6 do
    textLabel.Text = "Almost done" .. string.rep(".",count)
    wait(.3)
end

2 answers

Log in to vote
1
Answered by
XAXA 1569 Moderation Voter
8 years ago

Starting at line 14, you tried loading a Sound as local sound = Instance.new.sound(334321597). That is not how you use Instance.new. Instance.new(classname, Parent) creates a new object with classname (as a string, so in your case it would be "Sound") under Parent (since you want it to only play for the player, it would be under PlayerGui.

It looks like you also tried to load the sound as 334321597. This isn't the right way of loading an asset. In your case, you would prepend it with http://www.roblox.com/asset/?id=, so your final string would be "http://www.roblox.com/asset/?id=334321597".

Lastly, to play a sound, you should actually call the :Play() method on it.

You should replace line 14 with the following:

local sound = Instance.new("Sound", PlayerGui)
sound.SoundId = "http://www.roblox.com/asset/?id=334321597"
sound:Play()

Useful link: http://wiki.roblox.com/index.php?title=API:Class/Sound

Ad
Log in to vote
0
Answered by 8 years ago

You should use ContentProvider instead of a wait time.

Answer this question