Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

SoundId wont load from module script?

I am working on a local script that gets certain variables from a module script.

In this case I want a sound's soundId to get it's ID from a module script.

However when I run the script, it errors and says:

Players.plancenoit.Backpack.Anchornov_10.GunScript:40: bad argument #3 to 'SoundId' (string expected, got nil)

Heres the local script:

--<Variables>--

local player = game.Players.LocalPlayer
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local ModuleFolder = game.ServerScriptService:WaitForChild("Modules")
local toolModule = require(ModuleFolder:WaitForChild(tool.Name))
local values = tool:WaitForChild("Values")
local animationFolder = tool:WaitForChild("Animations")
local sounds = handle:WaitForChild("Sounds")
local canShoot = true

--<Gun Settings>--

local damage = toolModule[tool.Name.."Damage"]
local headshotDamage = toolModule[tool.Name.."HeadShotDamage"]
local magCapacity = toolModule[tool.Name.."MagCapacity"]
local storedAmmoAmount = toolModule[tool.Name.."StoredAmmoAmount"]
local maxStoredAmmoAmount = toolModule[tool.Name.."MaxStoredAmmoAmount"]
local fireRate = toolModule[tool.Name.."FireRate"]
local reloadTime = toolModule[tool.Name.."ReloadTime"]
local fireMode = toolModule[tool.Name.."FireMode"]
local weaponDisplayName = toolModule[tool.Name.."DisplayName"]

-----------------------------

local fireSound = toolModule[tool.Name.."FireSound"]

-----------------------------

local idleAnimation = toolModule[tool.Name.."IdleAnimation"]


--<Sounds>--
	
local fire = sounds:WaitForChild("Fire")
fire.SoundId = fireSound

--<Animations>--
	
repeat wait() until player.Character.Humanoid
	
local idle = animationFolder:WaitForChild("Idle")
idle.AnimationId = idleAnimation
	
--Loading Animations Below
	
local idleTrack = player.Character.Humanoid:LoadAnimation(idle)	
	


--<Body>--

tool.Equipped:Connect(function()
	
	idleTrack:Play()
	
end)

and here is my module script:

local Anchornov_10 = {}

Anchornov_10.Damage = 20
Anchornov_10.HeadShotDamage = 55
Anchornov_10.MagCapacity = 12
Anchornov_10.StoredAmmoAmount = 72
Anchornov_10.MaxStoredAmmoAmount = 72
Anchornov_10.FireRate = 0.2
Anchornov_10.ReloadTime = 2
Anchornov_10.FireMode = "Semi"
--Anchornov_10.ShotgunEnabled = false
Anchornov_10.FireSound = "rbxassetid://285027487"
Anchornov_10.IdleAnimation = "rbxassetid://976664412"
Anchornov_10.DisplayName = "Anchornov 10"


return Anchornov_10


1 comment

0

I am hella confused. Are you trying to set the SoundId with the parent's name and then concentate add a string after it?

1 answer

You are attempting to set a variable named fire's SoundId and then end it with a string that consists of non-numeral text.

SoundId has to consist with only the ID or a link with the ID added in the correct places.

Example of a soundid modification:

sound.SoundId = "https://www.roblox.com/library/362657146/Music"

The SoundId consists of a string value that contains the ID in the correct places.

This discussion is preserved as it was. New answers, comments, and votes are closed.