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

I can't seem to make a GUI appear when the player equips a tool. Any help?

Asked by 5 years ago

I am trying to help my friend with a menu for his airline group and I'm making a menu for him. I have the Menu GUI done but for whatever reason, I can't seem to make the GUI appear when you equip the tool. If you can help I'll be really thankful. I'm usually good at scripting but for some reason, I just can't seem to find the solution to this.

Current Code -

local tool = script.Parent
local player = game.Players.LocalPlayer
local menuGui = game.ServerStorage.MenuGui

tool.Equipped:connect(function()
local menuGuiCopy = menuGui:Clone()
menuGuiCopy.Parent = player.PlayerGui
end)

(I have the finished GUI in ServerStorage)

0
Try put the UI in the tool and use Connect and not connect NiniBlackJackQc 1562 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Try this

local tool = script.Parent
local player = game.Players.LocalPlayer
local menuGui = tool:WaitForChild('MenuGui')

tool.Equipped:Connect(function()
    local menuGuiCopy = menuGui:Clone()
    menuGuiCopy.Parent = player.PlayerGui
end)

It work for me

0
The issue was that the GUI was in ServerStorage, and the point of server storage is to store things on the server, and so the client does not have access to the contents of server storage. A move to somewhere where a player could see it, most preferably the tool would fix the issue. User#24403 69 — 5y
0
This worked, although I had to change the script to a local script, and the finished GUI's parent to the tool. Thanks for the help! sirgrayknight 4 — 5y
0
@sirgrayknight Yess it's sure! You must use a LocalScript! NiniBlackJackQc 1562 — 5y
0
I know, I got it to work. sirgrayknight 4 — 5y
Ad
Log in to vote
0
Answered by
Plieax 66
5 years ago

Make sure the script you are using is a LocalScript. Also you may not have the GUI enabled. One more thing use Connect not connect :)

local tool = script.Parent
local player = game.Players.LocalPlayer
local menuGui = game.ServerStorage.MenuGui

tool.Equipped:Connect(function()
local menuGuiCopy = menuGui:Clone()
menuGuiCopy.Parent = player.PlayerGui
menuGuiCopy.Enabled = true
end)

Answer this question