You’d probably wanna connect to CharacterAdded
, which when it fires you play the audio.
Alternatively, you can connect to CharacterAppearanceLoaded
to ensure the character is actually in Workspace, see this for the reasoning.
The code would look something like this:
local Players = game:GetService("Players")
local Client = Players.LocalPlayer
local Sound = ... -- Path to the sound
local function OnCharacterAppearanceLoaded(Character)
Sound:Play()
end
if Client.Character then
OnCharacterAppearanceLoaded(Client.Character)
end
Client.CharacterAppearanceLoaded:Connect(OnCharacterAppearanceLoaded)