#Physical music toggle model

121 messages · Page 1 of 1 (latest)

nimble wasp
#

Hi, I'm currently trying to set up a physical radio model in my social hangout game which users can walk up to and mute the music on their game with, but the way I have it currently configured, it mutes the music for every person in the game and if one person mutes it then nobody can hear it. How can I fix it so when someone interacts with the radio model, it only mutes their music?

#

Also, I would like to add that the audio is coming from the part itself, and i have very little experience scripting. Thank you to anyone who can help.

limpid sparrow
#

no hate to you at all, you're still figuring things out. the fix is very simple

#

studio allows you to create 2 different types of script: a local script and a server script (commonly referred to as a regular script or just a script)

#

server scripts work by replicating any of its actions to all clients (players), while a local script works by only affecting the player

#

basically you just need to use a local script rather than a server script

#

i would highly recommend you look into filtering enabled

#

it really helps you to understand the functionality and reasons for server-client relations

nimble wasp
#

do i have to change the actual script inside of it?

nimble wasp
#

i just changed the script to a local script

#

and used the same script

#

and it didnt work

limpid sparrow
#

could i see the script?

#

use that format to send it

limpid sparrow
nimble wasp
#

heres the script

#

it works when it was a regular script

limpid sparrow
#

so the script wont work at all when its a a local script?

nimble wasp
#

yes

#

the proximity prompt just does nothing

limpid sparrow
#

thats what you do want happening

#

local scripts (with a few exceptions) wont work in the workspace

#

i believe if you put the radio in replicatedFirst your local script should work

nimble wasp
#

ok lets see

#

then the radio goes away

limpid sparrow
#

wait lemme see something

#

ok you'll have to use remote events

#

do you know how to use those?

nimble wasp
#

no

spring ridgeBOT
#

studio** You are now Level 5! **studio

limpid sparrow
#

they're very simple

#

it basically can send information from a local script to a server script and vice versa

nimble wasp
#

oh wait

#

is it so i can have a local script in replicatedfirst thats actually connected to the model

#

without the model being its parent?

limpid sparrow
#

not quite

#

you can have a server script in the radio model and a local script in a client service

#

you can run the remote event on the server script and make the local script disable the radio for only the player

#

you should probably look into remote events

#

just lmk once you've done that and ill help you set a remote event up

nimble wasp
#

ok

#

so i set up the radio model back to how it was before i created this help thread

#

then i put the same script in a local script in replicatedfirst

limpid sparrow
#

not quite

#

put the local script in starter player scripts

#

the remote event will go in replicated storage

nimble wasp
#

ok

#

replicated storage or replicated first

limpid sparrow
#

storage

nimble wasp
#

ok

#

there

limpid sparrow
#

yea that'll work

#

so whenever a player disables it

#

in ther server script, do this code

nimble wasp
#

what do i do now to make it work

limpid sparrow
#
local RS = game:GetService("ReplicatedStorage")
local radioEvent = RS:FindFirstChild("radio")

local playing = true

script.Parent.ProzimityPrompt.Triggered:Connect(function(player)
  radioEvent:FireClient(player, (not playing))
end)
#

then in your local script

#
local RS = game:GetService("ReplicatedStorage")
local radioEvent = RS:FindFirstChild("radio")

radioEvent.OnClientEvent:Connect(function(playing)
  if playing then
    workspace["Radio model"].Sound.Volume = 0
    return
  end

  workspace["Radio model"].Sound.Volume = 1
end)
#

that should work

nimble wasp
#

ok one sec let me try to figure this out

limpid sparrow
#

ok

nimble wasp
#

is this right?

#

its not working

#

is it easier if i stream this to u

#

@limpid sparrow

limpid sparrow
#

oh so sorry

#

i went downstairs for a bit

nimble wasp
#

all good

limpid sparrow
#

is nothing happening?

nimble wasp
#

yeah

#

i can stream it

#

if u want

limpid sparrow
#

thats okay

#

i have a good visual for whats happening

nimble wasp
#

i renamed all the scripts involved radio and the remote event radio so its easier for me

#

here let me show u everything

limpid sparrow
#

whats that script?

nimble wasp
limpid sparrow
nimble wasp
#

look at the top

limpid sparrow
#

oh okay

nimble wasp
#

thats everything

limpid sparrow
#

can you go to the view tab at the top of studio for me?

nimble wasp
#

yeah

limpid sparrow
#

i figured as much

#

so thats called the output

#

its your best friend when debugging (fixing) a program

#

right now theres an error with the code

#

i misspelled Proximity

nimble wasp
#

💀

#

oh

#

thats hella funny

limpid sparrow
#

here ill send the server script again but fixed

#

i forgot to add a line anyway

#
local RS = game:GetService("ReplicatedStorage")
local radioEvent = RS:FindFirstChild("radio")

local playing = true

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
  radioEvent:FireClient(player, (not playing))
  playing = not playing
end)
#

there

#

that'll work for you

nimble wasp
#

thats for the serverscript then?

limpid sparrow
#

yes

nimble wasp
#

ok i think its working

#

let me test

limpid sparrow
#

yippee!

nimble wasp
#

um

limpid sparrow
#

uh oh

#

what happened

nimble wasp
#

can you join my game real quick