"Handle is not a valid member of tool" - Error????
I have two weapons I've made & scripted using the same fashion for both. One works completely fine (M1911) & the other (Ak-47) doesn't work at all. Now I know its because of this one error that keeps popping up, "Handle is not a valid member of tool"? I have a handle inside of my tool exactly like my M1911 which works just fine. Now note my Ak did work at one point before I tried adding sound effects for, equip, reload, magazine in, & empty clip effects. Also note that I added the same effects with different audio for the M1911. The script below is my main code and mind you im getting an error for the handle under my variables where I define handle.
003 | local tool = script.Parent.Parent |
004 | local hole = tool.barrel |
005 | local handle = tool.Handle |
007 | local config = tool.Config |
008 | local ammo = config.Ammo |
009 | local maxammo = config.MaxAmmo |
010 | local dmg = config.Damage |
011 | local allowtrace = config.AllowTracing |
012 | local clips = config.Clips |
013 | local range = config.Range |
014 | local plr = game:GetService( "Players" ).LocalPlayer |
015 | local cooldown = config.CoolDown |
016 | local mouse = game.Players.LocalPlayer:GetMouse() |
017 | local reloadtime = config.ReloadTime |
018 | local isReloading = false |
020 | local reload = tool.Handle.reloadAK |
021 | local fire = tool.Handle.akfire |
022 | local equip = tool.Handle.EquipSound |
023 | local empty = tool.Handle.emptyclip |
024 | local magin = tool.Handle.Magazinein |
029 | tool.Equipped:Connect( function (mouse) |
031 | tool.Activated:Connect( function () |
032 | if not isReloading then |
033 | if ammo.Value > 0 then |
040 | local ray = Ray.new(hole.CFrame.p, (mouse.hit.p - hole.CFrame.p) * range.Value) |
041 | local hit, position = workspace:FindPartOnRay(ray, plr.Character, false , true ) |
043 | if allowtrace.Value = = true then |
045 | local trace = Instance.new( "Part" , workspace) |
046 | trace.Material = Enum.Material.Plastic |
047 | trace.BrickColor = BrickColor.new( "Really black" ) |
048 | trace.CanCollide = false |
049 | trace.Anchored = true |
051 | trace.Transparency = 0.2 |
054 | local distance = (hole.CFrame.p - position).magnitude |
055 | trace.Size = Vector 3. new( 0.22 , 0.1 , distance) |
056 | trace.CFrame = CFrame.new(hole.CFrame.p, position) * CFrame.new( 0 , 0 , -distance/ 2 ) |
059 | game:GetService( "Debris" ):AddItem(trace, 0.1 ) |
065 | local humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
068 | if hit.Name = = "Head" then |
070 | humanoid:TakeDamage(dmg.Value* 2 ) |
074 | humanoid:TakeDamage(dmg.Value) |
078 | ammo.Value = ammo.Value - 1 |
089 | mouse.KeyDown:Connect( function (key) |
092 | if not isReloading then |
093 | if clips.Value > 0 then |
096 | ammo.Value = maxammo.Value |
097 | clips.Value = clips.Value - 1 |
098 | wait(reloadtime.Value) |
Now ive gone through & placed notes where the sounds are called upon to play. Any other info to help me solve this I can also provide. Thanks for the help!
~GoodkidMad