Switching Tools
In my game I disabled the inventory on the bottom of the screen so I have to make a script to change tools. It works well but there's one problem and that is that you can press 1 or 2 over and over and you'll be holding both weapons and a bunch of them will clone in to the character.
Script (In a local script):
03 | local p = game.Players.LocalPlayer |
04 | local h = p.Character.Humanoid |
08 | e.KeyDown:connect( function (key) |
09 | if key:lower() = = "1" and not db then |
11 | p.Backpack.LinkedSword:Clone().Parent = p.Character |
12 | a = p.Character:findFirstChild( "PaintballGun" ) |
17 | e.KeyUp:connect( function (key) |
18 | if key:lower() = = "2" then |
20 | p.Backpack.PaintballGun:Clone().Parent = p.Character |
21 | b = p.Character:findFirstChild( "LinkedSword" ) |
EDIT: After using Fattycat17's answer, I get this error message:
13:33:03.755 - FindFirstChlid is not a valid member of Model
13:33:03.758 - Script 'Players.Player1.Backpack.Equip', Line 12
13:33:03.760 - stack end
13:33:03.761 - Disconnected event because of exception