hello there! I am an roblox game developer who mainly focuses on making 3d models or maps for my game, and I decided to make an welcome screen because it will make my own game project even more refreshing, I have tried to mix an two tutorial’s results so it will have some of these two tutorial video’s features,
firstly, the locked view camera for welcome screen,
this feature is from one of the Insighted( )'s tutorial video on youtube, I’ve followed his tutorial video well and the welcome screen camera function does works as intended, but it only works if the script that mutes the original sound region music in my game doesn’t exist in that welcome screen script, and I’m trying to get help for fix that issue.
Insighted’s video about Welcome Screen tutorial on roblox Studio: How to make a Main Menu Gui (Beginner Tutorial) // 2023 // Roblox Studio - YouTube
and for another features of welcome screen I’m making is the music that plays while players is on welcome screen.
I’ve used Virxuis’s video of making welcome screen for roblox, which have welcoming screen music system but it doesn’t had welcome screen cam system so I fused this script with Insighted’s script so it could work well, but real problem started when I added more script line for make it so original sound region music in my game(it works by putting audio named “Sound” into every single player’s model and that’s how I made mute button for that game I mentioned, but for some reasons, it doesn’t work on welcome screen) so I need you guy’s help for finish the welcome screen for my game! and I would gladly showcase you guys my game after it’s done with some of additions.
Virxuis’s video of Welcome Screen tutorial: How to make a welcome GUI with music (ROBLOX) [UPDATED] - YouTube
also I also got video of problem with the script, and I would show you guys the script what I have used and you guys could fix it and help me! and if needed, I could share you guys roblox studio files so it will be easier to fix. so here is video of problem with my welcome screen script and script code block.
the video:
local blur = game.Lighting.GUIBLUR
local startbutton = script.Parent.TextButton
local music = script.Parent.song
local mutebutton = script.Parent.Parent.MuteButtonGUI.TextButton
local plr = game.Players.LocalPlayer
local chara = plr.Character or plr.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.MenuCam.CFrame
if script.Parent.Enabled == true then
local music2 = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Sound") --the script would find Sound Region music that got implemented inside localplayer's characters in my game, like how mute button in my game already does, but for some reasons it didn't work...
mutebutton.Visible = false
music2.Playing = false
music:Play() --it makes the welcome screen music play, it was supposed to be loop until player presses the startbutton and GUI closes and music stops
end
startbutton.MouseButton1Click:Connect(function()
mutebutton.Visible = true
music2.Playing = true
blur.Enabled = false --it turns off the blurs in the welcome screen when startbutton is clicked.
music:Stop()
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
wait(1)
script.Parent.Enabled = false
end)
thanks for listening to my topic, I’m wishing that it can be solved well. -mari
Well… By only focusing on the error warning you got in output, the problem is this:
You are trying to access music2 variable from outside its scope. Change this:
if script.Parent.Enabled == true then
local music2 = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Sound")
mutebutton.Visible = false
music2.Playing = false
music:Play()
end
To this:
local music2 = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Sound")
if script.Parent.Enabled == true then
mutebutton.Visible = false
music2.Playing = false
music:Play()
end
But I cant be sure that fix the issue… Honestly Im highly against using those youtuber’s tutorials when creating a real game, are good to start understanding how stuff works, but should not be used as a main system of a game, cause usually are pretty basic and if the user dont fully understand why those are working will end up having something they cant fix.
Creating a Welcome Screen with music is pretty simple, I recommend you should understand how it works and create your own, instead of depending on external resources, specially if the system in question is simple
Hello, The error message “attempt to index nil with ‘Playing’” is indicating that you’re trying to access a field (‘Playing’) on a nil value. This is likely due to music2 being nil at the point of access.
To fix this, you can define music2 outside of the if condition at the start of the script, then later update its value if necessary.
Here is the corrected script:
local blur = game.Lighting.GUIBLUR
local startbutton = script.Parent.TextButton
local music = script.Parent.song
local mutebutton = script.Parent.Parent.MuteButtonGUI.TextButton
local plr = game.Players.LocalPlayer
local chara = plr.Character or plr.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local music2 = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Sound") -- Now music2 is defined at the start
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.MenuCam.CFrame
if script.Parent.Enabled == true then
mutebutton.Visible = false
if music2 then -- Check if music2 is not nil before accessing it
music2.Playing = false
end
music:Play()
end
startbutton.MouseButton1Click:Connect(function()
mutebutton.Visible = true
if music2 then -- Check if music2 is not nil before accessing it
music2.Playing = true
end
blur.Enabled = false
music:Stop()
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
wait(1)
script.Parent.Enabled = false
end)
hello there ;D everything worked very fine as you intended, now the camera thing is working well, even the welcome screen music part, everything in onto function, I salute for you for your amazing help, here is the video of it working as intended!
(you may ignore those welcome screen random texts, it’s pretty pointless little additions not gonna lie,)(that one random text shown in video is based of my last experience in roblox game named “booth game” which some of group of peoples who argued against me said that despite him have done fortunes of job for helping moderations teams who didn’t took care of remaining awful bypassed stuffs in roblox, I’m never playing booth game again lol)
so that’s it, I hope you have amazing night after this goodbye for now.