Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Im trying to get a GUI to show when I hold a tool, its not working. Any fixes?

I don't know why it isn't working

local Player = game:GetService("Players").LocalPlayer

local Tool = game.StarterPack.HighPad

Tool.Equipped:Connect(function()
    Player.PlayerGui.Tablet.OuterBody.Visible = true
	Player.PlayerGui.Tablet.OuterBody.Active = true
end)

Tool.Unequipped:Connect(function()
    Player.PlayerGui.Tablet.OuterBody.Visible = false
 	Player.PlayerGui.Tablet.OuterBody.Active = false
end)

2 answers

✓ Accepted answer

Put your gui in the tool. Then put this script in the tool:

script.Parent.Equipped:Connect(function()
     player = game.Players:FindFirstChild(script.Parent.Parent.Name)
     gui = script.Parent:FindFirstChild("GuiName"):Clone().Parent = game.Players:FindFirstChild(script.Parent.Parent.Name)
end)

script.Parent.Unequipped:Connect(function()
     game.Players[player].PlayerGui.GuiName:Destroy()
end)

This should fix your problem. If it doesn't, the output from this script in ROBLOX Studio should say something that is easy enough to understand and help you fix the issue.

You are connecting the function to the Equipped signal of the tool in StarterPack. When the player spawns, the tool will be cloned into the player's backpack but the script will continue to listen for when the tool which is in StarterPack is equipped. To fix this, you could put the script under the tool and replace this line

local Tool = game.StarterPack.HighPad

with this

local Tool = script.Parent

1 comment

0

Sadly, I have tried this before but it hasn't been working.

This discussion is preserved as it was. New answers, comments, and votes are closed.