Sound not playing

I’m making a jumpscare part but a jumpscare without sound is quite stupid: yet it’s won’t play the sound.

workspace.JumpscareZone.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		local jumpscare = workspace.JumpscareZone.Jumpscare:Clone()
		jumpscare.Parent = plr.PlayerGui
		local audio = Instance.new("Sound")
		audio.Name = "Jumpscare"
		audio.Parent = jumpscare
		audio.SoundId = 5351101493
		audio:Play()
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)
		wait(1)
		jumpscare:Destroy()
		audio:Destroy()
		local died = game.ReplicatedStorage.Died:Clone()
		died.Parent = plr.PlayerGui
		wait(5)
		plr:Kick("You died to face: when the lights break, quickly hide")
	end
end)

audio.SoundId = "rbxassetid://5351101493"

By reading out the script, I’m going to infer that jumpscare is a UI Instance, You can’t play sounds on UI, it won’t do anything.

Add the sound’s parent to workspace with local audio = Instance.new("Sound", workspace), or add it to the players HumanoidRootPart.

1 Like

Alright, I’ll try these two solutions.

1 Like