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

bad argument #3 to 'SoundId' (string expected, got nil)?

Asked by 8 years ago

So I'm working on a sound system that only plays to one client (Yes, I'm using FilteringEnabled), and all of my sounds are inside of a modulescript. I'im using 4 scripts (including the module), here they are. (My issue is, it keeps saying what the title says and never plays)

**** If you could help that'd mean a lot, Thank you. v Module Script named "Sounds"

local SoundModule =
{
    Birds = "176132295";
    Suburbia = "176132394";
    SpringSound = "175637232";
    DingDong = "173452642";
    MessageClose = "173452663";
    ClothingEquip = "174308578";
    Warp = "173452757";
    NPCMessage = "173452617";
    NanoSummon = "171951986";
    MissionAccept = "171951946";
    MissionComplete = "171951929";
};

return SoundModule

v LocalScript inside a button just to test to see if the sound works

local RS =game:GetService("ReplicatedStorage")
local EV = RS:WaitForChild("Events")
local SE = EV:WaitForChild("SoundEvent")
local MO = RS:WaitForChild("Modules")
local S = require(MO:WaitForChild("Sounds"))

local PLR = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    SE:FireServer(PLR,S.DingDong)
end)

v The Client Side Sound Handler

local RS =game:GetService("ReplicatedStorage")
local EV = RS:WaitForChild("Events")
local SE = EV:WaitForChild("SoundEvent")
local MO = RS:WaitForChild("Modules")
local SO = script.Parent:WaitForChild("Sound")

SE.OnClientEvent:connect(function(PLR,id)
    SO.SoundId = id
    SO:Play()
end)

v And the ServerSideHandler in Workspace

local RS =game:GetService("ReplicatedStorage")
local EV = RS:WaitForChild("Events")
local SE = EV:WaitForChild("SoundEvent")
local MO = RS:WaitForChild("Modules")

SE.OnServerEvent:connect(function(PLR,soundId)
    SE:FireClient(PLR,soundId)
end)
0
try putting SO.SoundId = tostring(id) at line 08, client side sound handler 1N0body 206 — 8y
0
ok thx TheShiningSavior 10 — 8y

1 answer

Log in to vote
0
Answered by
jtefurd 50
8 years ago

Ok so, your sound ids are in a table. try seperating each element with a ',' instead of ';'. Using ; is just ending the line, it wont distinguish between elements if you don't use a comma. Second off, for sound ids try this instead:

SO.SoundId = "rbxassetid://" .. id;
Ad

Answer this question