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

0 Why won't my sound that is each character play when activated by the game script?

Asked by 6 years ago

I have a world script that activates a sound object in each character but it seems to not be working. Any thoughts?

for i = 4, 1, -1 do
        UniversalText.Value = "Commencing in: " .. i
        for i, v in pairs(Players) do
            if v.Ingame.Value == true then
            v.Character.Boing1:Play()
            end
        end
        wait(1)
    end

1 answer

Log in to vote
0
Answered by 6 years ago

Well first of. What you did was to iterate through the whole table of players in the players service. I'll share a code and explain it.

--Script in some service in workspace or ServerScriptService
local players=game:GetService("Players"):GetPlayers();
for _,player in ipairs(players) do
    if(player.Character~=nil) then
        player.Character:FindFirstChild("UpperTorso"):FindFirstChild("Boing1"):Play()
    end
end
--The sound needs to have a parent that's a 3D object (Such as a brick in game)
--If your game is R6. Instead of "UpperTorso". Replace it with "Torso"
--So what we do here is to get all players to a table.
--Loop them through and then check if the character is loaded using if(...) then
--And if it isn't nil. Then find the UpperTorso and then find the audio Boing1 and play it
0
Darn, that didn't work either. bigbenbennett 18 — 6y
Ad

Answer this question