I need help with a script that isn't working

I got bored of my other testing projects so I wanted to make a new test, It’s basically a Bakery or something related. I wanted the game mostly to work on one script in server script service (I focused mostly on a Music System.), Can someone help me with this script? It does not work.

local MusicNameLabel = script.Parent.Parent.StarterGui.MusicGui.Frame.MusicName.Text
local hidebtn = script.Parent.Parent.StarterGui.MusicGui.hidebtn
local MusicGui = script.Parent.Parent.StarterGui.MusicGui
local showbtn = script.Parent.Parent.StarterGui.MusicGui.showbtn

--//Reset Disabler\\--
game:GetService('StarterGui'):SetCore("ResetButtonCallback",false)

--//Button Click\\--
hidebtn.MouseButton1Click:Connect(function()
	MusicGui.Frame.Visible = false
	showbtn.Visible = true
	hidebtn.Visible = false
end)

--//Music System\\--
script.m1:Play()
if script.m1.IsPlaying then
	MusicNameLabel = "test"
end
wait(60)
MusicNameLabel = "..."
script.m1:Stop()
wait(0.05)
MusicNameLabel = ".."
wait(0.05)
MusicNameLabel = "."
wait(0.05)
MusicNameLabel = "..."
wait(1)
script.m2:Play()
if script.m2.IsPlaying then
	MusicNameLabel = "test"
end
wait(120)
script.m2:Stop()
1 Like

Can you show me where exactly is that script located at? (The Hierarchy of it)

You set the parents wrong. Anything in StarterGui will be parented under the Player’s PlayerGui folder.

E.g:

• StarterGui
-TestGUI

When the Player Spawns
•Player
•PlayerGui
-TestGui

1 Like

Hello! Here is where the script is located:

[quote=“TrackoTheTaco, post:1, topic:608038”]

--//Button Click\\--
hidebtn.MouseButton1Click:Connect(function()
	MusicGui.Frame.Visible = false
	showbtn.Visible = true
	hidebtn.Visible = false
end)

Well first off, this should be in a LocalScript as it’s only listening for the Player’s Input.

(Not to mention, with a LocalScript, this will be a lot easier)

Oh yeah, Sorry It’s 1:51 AM and I am losing my mind right now. I will put the MouseButton1Click part in a local script inside the button.
It is still not working though. It does not play anything or change any text, Here is the code currently:

local MusicNameLabel = script.Parent.Parent.StarterGui.MusicGui.Frame.MusicName.Text
local hidebtn = script.Parent.Parent.StarterGui.MusicGui.hidebtn
local MusicGui = script.Parent.Parent.StarterGui.MusicGui
local showbtn = script.Parent.Parent.StarterGui.MusicGui.showbtn

--//Reset Disabler\\--
game:GetService('StarterGui'):SetCore("ResetButtonCallback",false)

--//Music System\\--
script.m1:Play()
if script.m1.IsPlaying then
	MusicNameLabel = "test"
end
wait(60)
MusicNameLabel = "..."
script.m1:Stop()
wait(0.05)
MusicNameLabel = ".."
wait(0.05)
MusicNameLabel = "."
wait(0.05)
MusicNameLabel = "..."
wait(1)
script.m2:Play()
if script.m2.IsPlaying then
	MusicNameLabel = "test"
end
wait(120)
script.m2:Stop()
2 Likes
wait(5) -- Extra Wait-time to make sure everything loads in

--[[
Everything under here is going to be Client-Sided. Which means only **you** (the player) can hear the music. Its not going to be synchronized with the whole server. Though, if that's what your looking for, you can Private Message me about it!
]]--

--This should be a LOCAL-SCRIPT under Frame--

--//Disable Reset Button
game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)

--//Player
local Player = game:GetService("Players").LocalPlayer

--//Gui Properties
local Frame = script.Parent
local MusicGui = Frame.Parent
local MusicName = Frame.MusicName.Text
local hidebtn = MusicGui.hidebtn
local showbtn = MusicGui.showbtn

--//Sounds
local m1 = script.m1 
local m2 = script.m2
--(Please make sure the SOUNDS are parented to this script!)--

m1:Play()
print("m1 is playing")

if m1.IsPlaying then 
    print("m1 IsPlaying = true")
   MusicName = "test"
end

wait(60)
MusicName = "..."
m1:Stop() --You can either :Stop() or :Pause()
wait(0.05)
MusicName = ".."
wait(0.05)
MusicName = "."
wait(0.05)
MusicName =  "..."
wait(1)
m2:Play() --Plays the second music 

print("m2 is playing")

if m2.IsPlaying then
    print(m2.IsPlaying)
   MusicName = "test"
end

wait(120) --2 Minutes
m2:Stop()

--The End

I am sorry if this does not work, as I am currently on mobile and its around 2 am, so there’s no way for me to test this out. If there are any errors, let me know and I will fix them ASAP!

I feel like this should work, It doesn’t work and the output is wrong because I put the m1 and m2 sounds in it, But it says that m1 is not a parent of the script, It actually is but the output is wrong and the script doesn’t work.
Screenshot_21 Screenshot_22

All of those Errors/Warns aren’t from the LocalScript. They’re from the Original Script which is located in ServerScriptService.Script

1 Like

Oh, Yes it is, Sorry it’s 2:37 AM and I can’t really concentrate. The script isn’t working though and there isn’t any output errors/messages from it.

1 Like

Interesting, well, I’m going to add print statements into the code to see where its Erroring/Pausing at.

I believe you can’t have sounds in server script service. Try placing it in workspace.
I also noticed that you are attempting to access the music gui, which isn’t possible.

I recommend you to start over again, by using remote events.
Tell me if you need help :slight_smile:

1 Like

If I was a good coder I would succeed in this, Since I only have 4 months of experience in coding, I don’t even know how to use Remote Functions and Remote events. :smile:

It’s actually fairly easy when you understand it.
Try looking at the docs https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events :slight_smile:

I’m happy to help