I’m having a problem with the FE gun kit and It’s giving me an error on these lines
Line 1:
local tracks = HandleToFire.FireSounds:GetChildren()
local rn = math.random(1, #tracks)
local track = tracks[rn]
Line 2:
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.KeyCode == Module.Controller.Fire then
OnFiring()
Line one is giving me an error for playing a sound when I fire the gun.
Line two is pretty self explanatory.
the tracks does not have anything in them. Thats why, so the folder/table is probably empty
local tracks = HandleToFire.FireSounds:GetChildren()
Is likely not building any table, so when you perform a length operation on the variable tracks nil/0 is returned and passed as the 2nd argument to the math.random() function call, which of course is invalid.
The folder has 3 sounds. I don’t know what’s the problem though.
So what’s the fix to the problem. I don’t really get it.
Can you share the organisation of instances in the explorer window?
local tracks = HandleToFire.FireSounds:GetChildren()
Should probably be:
local tracks = script.Parent.Handle.FireSounds:GetChildren()
i think ik whats wrong do:
tracks[math.random(1#tracks)]
this gets the stuff directly inside of the tabel. Instead of what you did before.
local rn = math.random(1, #tracks)
local track = tracks[rn]
That’s the same as this, just with one less step involved.
That is literally just a shortcut and will only result in shortened code.
Oh and you forgot a comma to separate 1 and #tracks
oh, well i’m stupid xDDDDDDDDD.
Is the 2nd line you provided causing any issues? If so then that’s because the if statement is missing an end statement.
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.KeyCode == Module.Controller.Fire then
OnFiring()
end
wait, can you like make the gun open sourced so we can look at the full gun to see it’s functionally. Just a request.