my script has the int4ention that every time a specific player "X" joins it starts an event, but the problem is that the audio is out of phase with the GUI, that is to say that the GUI and its animation starts first and at the last seconds after comes the audio and I don't know how to solve it.
the script:
local EntitieUser = require(script.ModuleScript)
local guiToClone = script.ENTETIE
local function CloneGuiToPlayerGui(player, guiToClone)
local playerGui = player:FindFirstChild("PlayerGui")
if playerGui then
local guiClone = guiToClone:Clone()
guiClone.Parent = playerGui
end
wait(5.1)
if guiToClone.Parent == playerGui then
guiToClone:Destroy()
end
end
local jugadoresEspecificos = {
["AngeLo_Fidem"] = true,
["Sename_Recordss"] = true,
}
game.Players.PlayerAdded:Connect(function(player)
local userId = tostring(player.UserId)
local playerData = EntitieUser.IDs[player.Name]
if jugadoresEspecificos[player.Name] then
for _, otherPlayer in ipairs(game.Players:GetPlayers()) do
EntitieUser.playSound(otherPlayer)
CloneGuiToPlayerGui(otherPlayer, guiToClone)
end
end
end)
and the fuction from Modulescript
function EntitieUser.playSound(player)
local playerData = EntitieUser.IDs[player.Name]
if playerData then
local sound = Instance.new("Sound")
sound.SoundId = playerData.SoundId
sound.Parent = game.Workspace
sound.Volume = 1
sound:Play()
task.wait(2)
sound.Ended:Connect(function()
sound:Destroy()
end)
end
