Sound not playing

Hey! This is a really simple problem, but I don’t understand why it occurs. Because the same ID does play in another Sound instance, in another script.

local Button = script.Parent
local FolderButtons = Button.Parent.Parent
local TycoonFolder = FolderButtons.Parent
local ValuesFolder = TycoonFolder:WaitForChild("Values")
local TycoonOwner = ValuesFolder:FindFirstChild("TycoonOwner")
local SS = game:GetService("ServerStorage")
local Conveyor = SS:WaitForChild("Conveyor1")
local StarterDropperButton = SS:WaitForChild("StarterDropperButton")
local Sound = Button:WaitForChild("Sound")

Button.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game:GetService("Players"):FindFirstChild(tostring(hit.Parent.Name))
		if player and player.Name == TycoonOwner.Value then
			Sound:Play()
			Sound.Looped = false
			Button.Parent:Destroy()
			Conveyor.Parent = TycoonFolder:WaitForChild("PurchasedItems")
			StarterDropperButton.Parent = FolderButtons
		end
	end
end)

There aren’t any errors.

1 Like

If the sound is a child of ‘Button’, and you
are destroying ‘Button.Parent’ then
you are also destroying your sound.

2 Likes

The issue is what @SelDraken said, basically because you destroy the parent of the sound, you also destroy the sound before it starts and finishes playing. This topic is similar to this topic from yesterday:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.