I'm trying to make it so that when a player presses E, a tool goes into their toolbar, but when I run this code and press E, in the explorer the tool is in the starter pack but not in the toolbar. (This is in a local script inside StarterPlayerScripts)
local Demo = game.Workspace.Demo local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then Demo.Parent = game.StarterPack end end)
In order to put a tool into someone's toolbar, you need to put it into their Backpack, which can be accessed through player.Backpack. So,we make a clone of the Demo tool and put that clone into the player's backpack
local Demo = game.Workspace.Demo local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then local DemoClone = Demo:Clone() -- the reason we want to clone it is so we can use the tool again, if we didn't clone the tool would be put into the player and would not be inside Workspace anymore to use later DemoClone.Parent = game.Players.LocalPlayer.Backpack--this is where to put then tool, not the starterpack. It will put the tool inside the local player's backpack end end)
Code without comments:
local Demo = game.Workspace.Demo local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then local DemoClone = Demo:Clone() DemoClone.Parent = game.Players.LocalPlayer.Backpack end end)