Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to auto equip a tool when a GUI button is pressed?

Asked by 5 years ago
Edited 5 years ago

So I'm trying to make a tool equip when a GUI button is pressed while the default backpack GUI is disabled. I got the backpack GUI disabled now all I need is the tool equipper

I've tried this

local UserInput = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Tool = game:GetService("ReplicatedStorage").PL42

UserInput.InputBegan:connect(function(Input)
    script.Parent.Buttons.Frame.TextButton.MouseButton1Click:Connect(function()
        wait(1)
        Tool.Parent = Character
    end)

end)

and it literally did nothing, can someone help?

0
if im not wrong placing it in the character should work TheluaBanana 946 — 5y
0
also u shouldnt need to disable backpack TheluaBanana 946 — 5y
0
wait nvm TheluaBanana 946 — 5y
0
do it from a server script? TheluaBanana 946 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited by User#24403 5 years ago

ISSUES

You don't need the UIS to activate a GuiButton

Tools go into the player's Backpack to be transferred to the player Character, not directly to the character

Use Activated since it works for all devices while MouseButton1Click does not.

Revised Local Script

local Player = game:GetService("Players").LocalPlayer
local Tool = game:GetService("ReplicatedStorage"):WaitForChild("PL42")

script.Parent.Buttons.Frame.TextButton.Activated:Connect(function()
    wait(1)
    Tool.Parent = Player.Backpack
end)
0
so it'll not auto equip? RealCoolGuysworld 3 — 5y
0
what about humanoid:Equiptool(Tool) colivs 2 — 5y
0
:WaitForChild() overkill User#24403 69 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago

This should work

local UserInput = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Tool = game:GetService("ReplicatedStorage").PL42

UserInput.InputBegan:connect(function(Input)
    script.Parent.Buttons.Frame.TextButton.MouseButton1Click:Connect(function()
        Tool.Parent = Player.Backpack
        wait()
        Tool.Parent = Character

    end)

end)

this worked for me but idk if they fixed it or not

0
well it technically in't a fix, bt more like a change FlabbyBoiii 81 — 5y

Answer this question