Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

3 comments

0

localscript

0

what do you mean "you can only hear it" plz elaborate

0

play the sound in the player gui

1 answer

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)

5 comments

0

BUt The Sound wont work

0

Where is the sound placed?

0

@SnekyGodZ put the sound in ScreenGui.

0

i renamed the sound coinpickup and i made the script also named coinpickup placed it in the screengui doesnt work

0

Why is it still script.Parent when it's in PlayerGui?

This discussion is preserved as it was. New answers, comments, and votes are closed.