Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why would my Instance.New sound wouldn't be in the game?

So I have a part that would suppose to make a instance.new sound and would play. But for some reason, the instance.new sound wouldn't be in the PlayerGui or really, anywhere. Let me know anything I did wrong.

Script:

trigger = script.Parent
debounce = false


trigger.Touched:Connect(function(hit)
if not debounce then
debounce = true
	local sound = Instance.new("Sound", game.Players[hit.Parent.Name].PlayerGui)
	sound.SoundId = "rbxassetid://333430981"
	sound.Volume = 3
	sound.Looped = true
	sound.Name = "Glitch"
    game.Players[hit.Parent.Name].PlayerGui.Glitch:Play()
end	
	end)

3 comments

0

Why are you parenting it to the PlayerGui? Why not their character or something ?

0

Would it make a difference? Cause i'm new to scripting

0

Make sure you are using a local script for PlayerGui

1 answer

✓ Accepted answer

#Problems • Firstly, the second argument of Instance.new was deprecated, therefore it may be wonky and not preform the anticipated job.

• Secondly, a Sound will only play in a physical environment - workspace


These are mostly the issues that will be causing the kerfuffle you’re experiencing. The solutions are quite easy:

##A.

local Sound = Instance.new("Sound")

##B.

Sound.Parent = workspace

This discussion is preserved as it was. New answers, comments, and votes are closed.