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

Short sound doesn't play when activated in a script?

Asked by
hoth7 45
3 years ago

So, I made this script that transfers "Keys" into "Money", the only issue I'm having right now is that when the "Keys" are sold, It doesn't set "Playing" in the "MoneySound" to true.

script.Parent.Touched:Connect(function(hit)
    local H = hit.Parent:FindFirstChild("Humanoid")

    if H then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local Keys = player.leaderstats.Keys
        local Money = player.leaderstats.Money
        local MoneySound = game.ReplicatedStorage.Sounds.MoneySound
        local DeclinedSound = game.ReplicatedStorage.Sounds.Declined
        if Keys.Value >= 0 then
            MoneySound:Play() -- This is where i'm having the issue
            Money.Value = Money.Value + Keys.Value
            Keys.Value = 0
        else
            game.ReplicatedStorage.Remotevents.CantSell:FireAllClients("Cant sell!") -- this also doesn't work for some reason even though its coded correctly.
            DeclinedSound:Play() -- This is where i'm having the issue as well
            end
    else
        return
        end
    end)

Oh and I forgot to include this, but if the player doesn't have more than 0 keys, a declined sound will play, however, this also doesn't play. No, It's not my headphones, because the background music works. There are also no errors in the output. Please no useless one-word answers, I've already tried them all. Help needed!

1 answer

Log in to vote
0
Answered by 3 years ago

try to set timeposition before you play it, maybe volume.

MoneySound.TimePosition = 0
MoneySound.Volume = 0
MoneySound:Play()

If this does not work, it may be problem of sound location, try to place them at workspace or somewhere else.

0
It was in replicated storage. hoth7 45 — 3y
Ad

Answer this question