Any Way to grab a sound that is in workspace from an object value and then stop it?

look. i changed it back into object value.

i also removed the IF AUDIOVALUE IS NIL RETURN thing and it still gave me no error but it didint work

then TapeValue.Value is not what you want to achieve. Simply, you’d need to use a RemoteEvent to call the state of your Audio if its playing or not. If you only want for the LocalPlayer to achieve the skip or else it will skip for everyone else.

The simplest way is using RemoteEvents, and not using too much of the Values

  • place a RemoteEvent and name it however you wanted

Server Side Script:

  • Fire the client to send the state of your Audio if its playing or not
  • is inside the ProximityPrompt

Client Side Script:

  • it will listen whenever if your audio is playing or not
    .
    – if its playing, then the CanSkip Value will turn true
    – and the function to be able to Skip by Pressing F is doable
    .
    – However, if CanSkip is false
    – then the audio is not playing at all

OHHHHH. i get it. it doesnt detect this. even tho they are the same.
image

yes and will always return nil, as what I said in my previous comment


and if your script inside the Proximity is a Normal Script, and your 2nd script is a LocalScript then it won’t work (in some instances) and you’d need to actually use remote events for it.

well im stumped. im not rlly good at remote events unless its something easy. like enabling a value or a gui frame or smth

oh my god. i have an idea. stopping all the audio in the tapes folder.

is the game for multi-player or solo only?

singleplayer. most games i make are singleplayer. to make it easier

where does your local script parented to the one that can skip the audios? I’m trying to make the template here for you and see if this will be helpful for you

local script parented to the player. its in starterplayerscripts

also i tried using the stopping all audios thing. i did a [VARIABLE = FOLDER:GETCHILDREN()]

and i got this error when i tried stopping the audios.
image

welp, since its in StarterPlayerScripts you’d really need to use RemoteEvent for it to work, not just simply locating the values inside workspace.

no i changed some stuff. to make it so i stop all audios. but i got this error when i did GETCHILDREN
image

im not using values anymore. only the CANSKIP value. which works

get children only gets all of the children that are listen down in a folder, you’d want to specificy for each folders. Or just simply place them all in 1 folder.

all the audios for the tapes will be in the same folder

so here’s what I got for you to start with Remote Events,

inside the proximity prompt this is what your code would look like:

local PROMPT	= script.Parent
local REP_SERV	= game:GetService("ReplicatedStorage")

local R_EVENT	= REP_SERV:WaitForChild("PlayerValue") -- // Put Name of your Remote Event here

local function SoundUpdateValue()
	-- // Your other script here
	-- // You'd mostly put here the ones that will get affected in Workspace
	
	R_EVENT.FireAllClient(true) 	-- // You will be sending the Value to return it True
	task.wait(1) 					-- // This will wait for FireClient to get fired before disabling the Prompt
	PROMPT.Enabled = false 	-- // You can also add this so when you have picked up the audio, it won't be triggered again
end

PROMPT.Triggered:Connect(SoundUpdateValue)	-- // You'd call the local function SoundUpdateValue here
											-- // so whenever the Prompt get's triggered, it will FireClient

on the local script, this should look like:

local REP_SERV	= game:GetService("ReplicatedStorage")

local R_EVENT	= REP_SERV:WaitForChild("PlayerValue") -- // Put Name of your Remote Event here

R_EVENT.OnClientEvent:Connect(function(state)
	local BOOL = false
	BOOL = state 			-- // This will listen whenever the Event gets Fired via Client or Server
	
	if BOOL == true then
			-- // script here
	else
			-- // here too
	end	
end)

You’d want to specifically locate where your audio would be inside the local script, let me know if you find it helpful and explore first for yourself and come back here if you ever came across a error.

Here’s how it works:

  • Proximity Prompt get’s triggered
  • Server Side Script fires Value(True) to Client Side Script
  • Client Side Script listens to the Event and gets the Value (which is “true”)
  • Client then makes the Bool State (which is previously false) to True
  • So whenever the Bool = True your “if and then” statements will function
  • If the Bool = true, there goes your script whenever you want to stop the Audio
  • Then if the Bool = false, set an instance or just use “print(“Bool is False”)”, or just remove the “else”

Both templates are General, so you can do this scenario

  1. Copy and Paste ProximityPrompt Object in every Audio with a Part parented
    – This will make you need to add different stuff to the script as tables on the LocalScript to reference which script is passing/firing the value.
    – Tables will help you to reference which are being triggered, and which audio you specifically need to stop for the Skip to function. Your LocalScript’s Table will look like this:
local Table = {
    [1] = "This is a Text", -- Add a comma
    [2] = "This is another Text"
}

-- In referencing it, you would do like:
print(Table[1])

oh sorry. i was testing out some stuff and yeah remote events were the solution. i realised u cant stop audio that was played with a server script through a local script.

i basically just stopped all audio in the tapes folder. but ye i will mark u as solution. ty

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.