#how do i make it come from only one place
209 messages · Page 1 of 1 (latest)
if you're playing it from a script it's going to play globally
you need to use a local script
or maybe fire a remote event to a client
oh
i feel foolish now
it still plays globally
globally like across the map i meant
maybe bad phrasing
i did that and its still global
** You are now Level 4! **
i can like stream or clip it if that helps
im trying to make it play from a radio
workspace part at the position where u want it to play
yes so parent the audio to the radio
play it
then wait till its finished n deletr it
uh huh uh huh
play it
yeah
yeah
emmm
its in a folder
do i gotta take it out of the folder
it is now in the workspace and not in the folder
the part can be in a folder just make sure ur playing the audio that's a child of the part and not the ones that are a child of the script
ok
the ones in the script are not playing and the ones out of the script are playing
it is just playing every song at once am i foolish
they are on isplaying and not on looped
does it work
do something like
local audioFolder = …
local function playAudio()
local audio = nil
local randomNumber = math.random(1, 5) — or howveer many audios you have
for i, v in pairs(audioFolder:GetChildren()
if i == randomNumber then
audio = v
end
end
local clonedAudio = audio:Clone()
clonedAudio.Parent = - part you wanna parent it to
clonedAudio:Play()
clonedAudio.Ended:Wait()
clonedAudio:Delete()
end
so it's still playing all the songs at once or
playing nothing at all
if it doesnt work its cus im on mobile and its hard to code
can i see the properties of the sound
and is the code any different from the first one u posted
the code is trhe same but its in a localscript now
if it's the same then it would be playing the sounds that are children of the script
oh yeah and locks scripts won't work i. the workspace
local
so put that in like starterplayerscripts or something
we're trying to play the sounds that are children of a part right
should i just turn it into a regular script again??
no put the script in starterplayerscripts
ok give me a second
it is now in starterplayerscripts
now can you show me a picture of the part in workspace where we have all the sounds
i love duster
duster is based
so make local sounds = workspace.radio:getchildren()
GetChildren()*
even better do workspace:waitforchild("radio")
thats so real
are you sure it shouldnt be a normal script i wanted it to play the same song for everyone
would it not be random for everyone if it was a local script
i didnt want it to be played across the entire map that is the issue i have been having
put it in like serverscriptservice or something
i got confused about this
that's okay
so should i delete the old local script
yeah
ok that part is done
so what do you have now
uhh
like the same thing i took a screenshot of before but its a normal script in serverscriptstorage
got stuck on that sorry
is it working
and radio still has all the sounds in it?
big cee
yeah hold on i never checked if it works
you can delete all the sounds from beneath the script
i did that i think
it does not
any errors
sre you printing
how do i check that again
** You are now Level 5! **
everytime it runs
** You are now Level 4! **
idk what printing means to be honest
bro
bro what
sorry sir
never coded before sir
go to view and turn on output
print is basically a way to help debug
did you change the script to look for children of radio instead of children of the script
no hold on sorry i completely forgot
that should fix it
dont apologize
it is exactly the same i dont think i did it right
show us line 4
uhh
show the whole script
like in the output thing
ok
wait(1)
while true do
local Sounds = script:GetChildren()
local RandomIndex = math.random(1,#Sounds)
local RandomSound = Sounds[RandomIndex]
RandomSound:Play()
wait(RandomSound.TimeLength)
end
workspace.radio.getchildren()
huh
i dnto know what im doing
you see where it says local sounds
we're trying to change that
i get it i get it
we don't want Sounds to be the children of script we want it to be radio
yeah i think i get it now
nice
is radio a child of workspace or a folder or something
** You are now Level 10! **
child of workspace
we need to properly reference the radio part
ok cool
wait(1)
while true do
workspace.radio.GetChildren() = script:GetChildren()
local RandomIndex = math.random(1,#Sounds)
local RandomSound = Sounds[RandomIndex]
RandomSound:Play()
wait(RandomSound.TimeLength)
end
this is what i put is this right
idk why its bringing up the fog part now
uh u did something really weird
tell me so i dont look foolish later
like it's just a way to use shorthand so we don't need to type a lot of stuff
ok ok
so instead of typing radio:getchildren() every time we can just type Sounds
you used to define the Sounds variable here
but instead for some reason you're trying to declare that radio:getchildren() should equal script:getchildren()
which is nonsensical
uh huh uh huh
the fog part thing is from a different script entirely
yeah
how do i do that...
so i. the original code you had you were defining the Sounds variable as script:getchildren() because all the sounds were children of the script right
but we've changed that now so that the sounds are children of the workspace part
so instead we need to define Sounds as the children of the radio part
you see what i'm saying
maybe... i am stupid
that was a lot simpler than i thought it wsa
thank you both
it always is
its honestly extremely simple im ngl
idk how it took you so long
of course!!
i have never scripted before and to be honest i did not make this my friend gave me it since we are both working on this and it did not work
yeah i learned hella thank you both