Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't the sound play when all buzzers have been pushed?

Asked by
Hypoxla 125
4 years ago

There are 4 buzzers, and I put both of these scripts in each buzzer and none of them work;

I am also getting no errors in the output.

Script 1:

local button = script.Parent
local sound = game.Workspace.AGTDesk.GB.GoldenBuzzer
local X1 = game.Workspace.AGTDesk.X1
local X2 = game.Workspace.AGTDesk.X2
local X3 = game.Workspace.AGTDesk.X3
local X4 = game.Workspace.AGTDesk.X4
local color = BrickColor.new("Really red")

if X1.BrickColor == color and X2.BrickColor == color and X3.BrickColor == color and X4.BrickColor == color then
    sound:Play()
end

Script 2:

local button = script.Parent
local sound = game.Workspace.AGTDesk.GB.GoldenBuzzer
local X1 = game.Workspace.AGTDesk.X1
local X2 = game.Workspace.AGTDesk.X2
local X3 = game.Workspace.AGTDesk.X3
local X4 = game.Workspace.AGTDesk.X4
local color = BrickColor.new("Really red")

function buttonClick()
    if X1.BrickColor == "Really Red" and X2.BrickColor == "Really Red" and X3.BrickColor == "Really Red" and X4.BrickColor == "Really Red" then
        sound:Play()
    end

end

button.ClickDetector.MouseClick:Connect(buttonClick())
0
In both scripts: It will only works if all the parts are with the same color (Really Red). In script 2: You should use the if like you made in script 1. If you can explain better what you need, I can make an elaborated answer cailir 284 — 4y
0
I'm making a Got Talent game, and I want a sound to play and a decal to change when all 4 buzzers are active, meaning Color = Really Red. (I will decal changing later) Hypoxla 125 — 4y
0
In Script 1 you will have to use a loop to check if the buttons are in the color cailir 284 — 4y
0
I tried answering it. Hope it worked! Aztralzz 169 — 4y
View all comments (2 more)
0
why not putting x1-4 in a table? Jakob_Cashy 79 — 4y
0
"Really Red" is case sensitive put "Really red" instead for starters quinzt 201 — 4y

1 answer

Log in to vote
0
Answered by
Aztralzz 169
4 years ago
Edited 4 years ago

Try this:

    local button = script.Parent
    local sound = game.Workspace.AGTDesk.GB.GoldenBuzzer
    local X1 = game.Workspace.AGTDesk.X1
    local X2 = game.Workspace.AGTDesk.X2
    local X3 = game.Workspace.AGTDesk.X3
    local X4 = game.Workspace.AGTDesk.X4
    local color = BrickColor.new("Really red")
    function check() 
    if X1.BrickColor == color and X2.BrickColor == color and X3.BrickColor == color and X4.BrickColor == color then
        sound:Play()
    end end
    while true do
   check()
  print("loop") -- not needed, but its to check if the loop is working
 wait(0.5)
   end

Hope I got it all correct, best hopes for you!

0
I didn't test this. If it didn't work, I'll try some more. :) Aztralzz 169 — 4y
0
Very sorry but this didn't work for me. :( Hypoxla 125 — 4y
0
Oof. Aztralzz 169 — 4y
0
Any errors in output? Aztralzz 169 — 4y
View all comments (4 more)
0
Script timeout - Exhausted. Hypoxla 125 — 4y
0
Try increasing the wait time. Aztralzz 169 — 4y
0
Oh and, I don't think you need the script in every button. Maybe delete all of the script's except one, and put that script in ServerScriptService. If you do that, just so you know, you will have to change the local button, because it is not the parent of the script anymore. Aztralzz 169 — 4y
0
Try looking at this. It isn't centered around this certain problem but it talks about userinputs and if they are all clicked. https://scriptinghelpers.org/blog/creating-your-own-simon-says Aztralzz 169 — 4y
Ad

Answer this question