-- Placed in ServerScriptService (Server Side) local ReplicatedStorage = game:GetService("ReplicatedStorage") local PlaySoundEvent = Instance.new("RemoteEvent") PlaySoundEvent.Name = "PlaySoundEvent" PlaySoundEvent.Parent = ReplicatedStorage PlaySoundEvent.OnServerEvent:Connect(function(player, soundId) -- Validation: Ensure the soundId is safe or allowed in your game if type(soundId) == "string" and string.match(soundId, "^rbxassetid://%d+$") then local sound = Instance.new("Sound") sound.SoundId = soundId sound.Parent = player.Character or player.CharacterAdded:Wait() sound:Play() -- Clean up the sound object after it finishes playing sound.Ended:Connect(function() sound:Destroy() end) end end)