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
I am hella confused. Are you trying to set the SoundId with the parent's name and then concentate add a string after it?