Hello! Im making a script so that when you click a button you will equip a tool. I started it off but I don’t know how to refer to it. But there is also another thing. I want it so that the tool is being equipped and not shown in the backpack. So your holding the tool but the tool is not in your backpack.
script
script.Parent.MouseButton1Click:Connect(function()
? -- I don't know what goes here
end)
? -- I don't know how to make it so it won't show up in your backpack
I hope you can help me! Im not the best scripture and I want to learn. I will appreciate an explanation to your script.
Wow four local scripts… Are you sure you need all of them? Anyway use what MrChips said and if you don’t want the backpack to show up then use SetCoreGuiEnabled to stop it from showing up.
local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid = char.Humanoid
script.Parent.MouseButton1Click:Connect(function()
humanoid:EquipTool(YourTool)
end)
Since you were mentioning some knife,
Try to clone it from it, into the LocalPlayer’s backpack, once the button is pressed.
local plr = game:GetService("Players").LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local hum = chr:WaitForChild("Humanoid")
local gui = script.Parent --assuming you put the script in the gui directly
local knife = gui:FindFirstChild("Knife"):Clone()
local button = gui.Frame.ImageButton --change to whatever
button.MouseButton1Click:Connect(function()
local knife = gui:FindFirstChild("Knife"):Clone()
knife.Parent = plr.Backpack
end)
And since you were also asking what setcoreguienabled was,