Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
TtuNkK 37
5 years ago

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)
0
Why are you parenting it to the PlayerGui? Why not their character or something ? User#24403 69 — 5y
0
Would it make a difference? Cause i'm new to scripting TtuNkK 37 — 5y
0
Make sure you are using a local script for PlayerGui xEmmalyx 285 — 5y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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
Ad

Answer this question