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

How do i make when u collect a coin you can only hear it?

Asked by 4 years ago

hello i been trying to make a thing when u collect a coin you can only hear the sound please help

local db = true
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if db == true then
            db = false
            script.Parent.Transparency = 1
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5
            script.Sound:Play()
            script.Parent.Transparency = 1
            wait (13)
            db= true
            script.Parent.Transparency = 0
        end
    end 
end)
0
localscript greatneil80 2647 — 4y
0
what do you mean "you can only hear it" plz elaborate brokenVectors 525 — 4y
0
play the sound in the player gui Gooncreeper 98 — 4y

1 answer

Log in to vote
1
Answered by
SpiralRBX 224 Moderation Voter
4 years ago
Edited 4 years ago

Simple! Use a localscript to play the sound. You can also play it in the PlayerGui or simply move it to ScreenGui and when a server starts it will do it for you. I have rewrotten the script so that the sound will work if it is in the players PlayerGui. Simply drag it in to ScreenGui and let it play.

local db = true
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if db == true then
            db = false
            script.Parent.Transparency = 1
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5
           player:WaitForChild("PlayerGui").Sound:Play()
            script.Parent.Transparency = 1
            wait (13)
            db= true
            script.Parent.Transparency = 0
        end
    end 
end)
0
BUt The Sound wont work SnekyGodZ 19 — 4y
0
Where is the sound placed? SpiralRBX 224 — 4y
0
@SnekyGodZ put the sound in ScreenGui. SpiralRBX 224 — 4y
0
i renamed the sound coinpickup and i made the script also named coinpickup placed it in the screengui doesnt work SnekyGodZ 19 — 4y
0
Why is it still script.Parent when it's in PlayerGui? PrismaticFruits 842 — 4y
Ad

Answer this question