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

why wont my sound play when i touch a part?

Asked by 4 years ago
Edited 4 years ago
local enabled = false
script.Parent.Touched:Connect(function(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if not player then return end
    if not enabled then
        enabled = true
        wait(1)
        local sound = player.Backpack.wild_freedom
        sound:Play()
        enabled = false
        print("done")
    end
end)

prints done but no sound plays this is updated code

2 answers

Log in to vote
2
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Playing is a boolean property used to understand if the Sound is currently playing or not. It does not actually enable the Sound Object. Use the :Play() method of Sound to properly begin the soundtrack.

Sound Objects can only be heard within physical environments too, therefore, a Sound must be in workspace to fully operate. If you wish for the Sound to play locally to a Part, then simply store the Object within the Instance.

0
yea i tried to use :Play() but that did nothing Gameplayer365247v2 1055 — 4y
0
I made a late edit, please read again. Ziffixture 6913 — 4y
0
as you can see, the sound doesnt play https://imgur.com/a/TaCAj4M¨ Gameplayer365247v2 1055 — 4y
0
ok im gonna try with changing to workspace Gameplayer365247v2 1055 — 4y
0
worked Gameplayer365247v2 1055 — 4y
Ad
Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Backpack can't store values such like sounds, game stats, part properties and etc. Please put it on workspace and do this line:

local sound =  workspace.wild_freedom
0
oo wait the up post have marked as correct so uh i don't wanna delete, let me just put it here Xapelize 2658 — 4y
0
yeah, i only put the sound in the wrong service and feahren was quicker to explain that was the issue Gameplayer365247v2 1055 — 4y

Answer this question