So i have this script that should play a sound when someone joins my game, but it doesn't work. Please help me out!
sound = Instance.new("Sound", game.StarterPlayer.StarterPlayerScripts) sound.Id = "..." sound:Play()
(Also it should play only for you not for eveyone)
Firstly, why would you put a sound inside StarterPlayerScripts
which is intended for scripts for the player and Id isnt just three dots or its a placeholder for a ID. You could make this play locally by playing the Sound on a local script and parent the sound to StarterGui so it would play locally.
local player = game.Players.LocalPlayer local sound = Instance.new("Sound") sound.SoundId = "rbxassetid://"..--id here sound.Parent = player.PlayerGui sound:Play()
also this would have to be a local script since you can only access LocalPlayer on a LocalScript.
NOTE the parent parameter of Instance.new()
is deprecated, just set the parent last.
Create a sound with your desired ID inside of any client folder (SPS, StarterGui) - then just wait for its creation and play it once it is found.
local Sound = game.Players.LocalPlayer.PlayerGui:WaitForChild("Sound") Sound:Play()
If you want it to just play for one person, you'd have to make a localscript and use "LocalPlayer". So, you'd have to do this:
game.Players.PlayerAdded(function() local Sound = Instance.new("Sound") Sound.Parent = game.Players.LocalPlayer.PlayerGui Sound.SoundId = Id here Sound:Play() end)
Place the LocalScript inside of ServerScriptService as a LocalScript.