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

How do I fix this script so a sound plays whena part is touched?

Asked by 3 years ago

I'm trying to make a sound play when the player touches the sell pad but it seems to just pass through the sound no matter where I put it in the script.

No errors appear in the output, but when I made a mistake with the name it appeared in the output so I think the sound IS recognized by the script but I just don't know why it doesn't play.

code is in a server / global script.

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player.leaderstats.Power.Value >= 1 then
            player.PlayerGui.Cash:Play()
        game.ReplicatedStorage.BindableEvents.Sell:Fire(player)

    end 
    end
    end)
0
This is a Server Script right? Server Scripts can't see what's inside players' PlayerGui. You'll need a Local Script for that Spjureeedd 385 — 3y

Answer this question