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

Can someone give me the script for stopping a local sound?

So i'm recently working on a jailbreak-like game and i want to make the bank. the problem is not that i dont know how to play a sound localy cuz i have the script:


local brick = script.Parent
	local sound = script.Parent.Sound
	debounce = false
	brick.Touched:connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player and not debounce then
	debounce = true
	play = sound:Clone()
	play.Parent = player.PlayerGui
	play:Play()
	wait(5)
	debounce = false
	end
	end)

but...i cant make it stop! I've tried to lookup the script but i coundn't find it. Can you please give me the script for stopping the song please?

1 answer

First, do use the Lua Code Block and put the script inside it, for the helpers to read the script in an efficient way.

Second, the solution of your doubt: Well, the Sound object have property called :Stop() that can be used by a script and stop the music.

Well, you are free to ask for an example.

local Sound = Instance.new("Sound") -- Creating the sound object
Sound.Parent = game.StarterGui -- Make the created object, the child of StarteraGui, as it will play the sound locally

Sound.SoundId = "1234567890" -- Just an example

Sound:Play() -- Plays the sound
wait(2) -- waits for 2 seconds
Sound:Stop() -- Stops the sound

Tip : Don't write 'Provide me with a script', instead, write 'Can I get some help" etc..

Lemme know if it helps!

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