So I’m trying to make an Intro and I want to add sound to it. When the player joins they get a GUI and a sound but the script for the sound doesn’t work. I tried it myself but couldn’t get far since I didn’t know how to.
local Players = game:GetService("Players")
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://1175226216"
if not sound.IsLoaded then
sound.Loaded:wait()
end
function PlayerGUIstart()
wait(1)
sound:Play()
end
Players.PlayerAdded:Connect(PlayerGUIstart)
I want it that when the player joins the sound will play before anything else has been loaded in. Does anyone know how to do that.
Try making a local script in replicated first?? And since replicated first is a place where it’ll be loaded first, you have to use waitforchild if you want to access other things.
Just put a local script in ReplicatedFirst, and type this:
local Players = game:WaitForChild("Players")
local sound = Instance.new("Sound", game:WaitForChild("Workspace"))
sound.SoundId = "rbxassetid://1175226216"
if not sound.IsLoaded then
sound.Loaded:wait()
end
function PlayerGUIstart()
wait(1)
sound:Play()
sound.Playing = true
end
Players.PlayerAdded:Connect(PlayerGUIstart)
local Players = game:GetService("Players")
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://1175226216"
sound.Loaded:wait()
function PlayerGUIstart()
wait(1)
sound:Play()
end
Players.PlayerAdded:Connect(PlayerGUIstart)
local Players = game:WaitForChild("Players")
local sound = Instance.new("Sound", game:WaitForChild("Workspace"))
sound.SoundId = "rbxassetid://1175226216"
if not sound.IsLoaded then
sound.Loaded:wait()
end
function PlayerGUIstart()
wait(1)
sound:Play()
sound.Playing = true
sound.Played:Wait()
sound:Destroy()
end
Players.LocalPlayer.CharacterAdded:Connect(PlayerGUIstart)
There we go now it should work!
Edit: I tested it and it works! Great music choice @ardaboyroo, just put the script in replicated first. I cannot believe we put PlayerAdded in a local script instead of CharacterAdded, I also added so it destroys the sound after.