Thanks to ax_gold, got this working script now:
local player = game.Players.LocalPlayer local backpack = player.Backpack local character = player.Character local primary = backpack.Primary local secondary = backpack.Secondary function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.One then primary.Parent = character secondary.Parent = backpack elseif inputObject.KeyCode == Enum.KeyCode.Two then secondary.Parent = character primary.Parent = backpack end end game:GetService("UserInputService").InputBegan:connect(onKeyPress) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false); game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false); game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false);
EquipTool()
Likes to be especially stupid when it comes to roblox scripting. Instead, I usually just change the parent of the tool to the character in workspace, and it will automatically make them equip the tool. Here's an example with part of your script.
function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.One then backpack.Primary.Parent = character elseif inputObject.KeyCode == Enum.KeyCode.Two then backpack.Secondary.Parent = character end end
also, just a side note, but you might want to make a way to unequip the tool. If you need help with that too, let me know.