Empty
Empty
Empty
Le Service de Son est un service dans Roblox qui gère la lecture des sons dans votre jeu. Il vous permet de gérer les paramètres sonores globaux et la lecture pour la musique de fond, les annonces et d'autres sons qui doivent être entendus par tous les joueurs, quelle que soit leur position dans le monde du jeu.
Musique de Fond avec Boucle
Roblox Studio
Jouer un Son depuis un Script
Empty
Empty
Empty
- Script Serveur : Si un script côté serveur joue un son parenté à une partie dans le Workspace, il sera généralement entendu par tous les joueurs à proximité de cette partie.
- Script Local : Si un script côté client joue un son, seul le joueur exécutant le script l'entendra.
Empty
Empty
Empty
-- Workspace > SoundPart > PlayStepSoundScript
local soundPart = script.Parent
local stepSound = soundPart:WaitForChild("StepSound")
local function onTouched(otherPart)
local character = otherPart.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
stepSound:Play()
end
end
soundPart.Touched:Connect(onTouched)
Empty
Empty
Empty
-- StarterPlayerScripts > LocalStepSoundScript
local player = game.Players.LocalPlayer
local soundPart = workspace:WaitForChild("SoundPart")
local stepSound = soundPart:WaitForChild("StepSound")
local function onTouched(otherPart)
local character = otherPart.Parent
if character == player.Character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
stepSound:Play()
end
end
end
soundPart.Touched:Connect(onTouched)
Si ce tutoriel vous a été utile et que vous souhaitez soutenir mon travail, veuillez envisager de m'offrir un café.
Merci beaucoup pour votre soutien !
M'offrir un café