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

Why won't this gui appear when I equip the tool?

I am trying to make a gui of the tool, but first i just want to make a simple gui appear before moving on to anything else. I got a simple gui script, put it in playerGui and it worked perfectly, now that I have moved it to appear on equip, it doesn't work. Any thoughts?

local tool = script.Parent


local player = game.Players.LocalPlayer

tool.Equipped:connect(function(mouse)
	local screenGui = Instance.new("ScreenGui")
screenGui.Parent = script.Parent.Parent
local textLabel = Instance.new("TextLabel")
textLabel.Parent = screenGui
textLabel.Position = UDim2.new(0, 25, 0, 50)
textLabel.Size = UDim2.new(0, 150, 0, 50)
textLabel.BackgroundColor3 = BrickColor.White().Color
textLabel.Text = "Hello ROBLOX!"

end)

2 comments

1

Ur placing the gui inside the character because when you equip it the script.Parent.Parent is the character and not the PlayerGui

1

at line 8 it should be screenGui.Parent = player.PlayerGui

1 answer

✓ Accepted answer

This is because you are actually parenting the GUI to the Character. In order to make the GUI appear on the player's screen, you'll need to put it in the player's PlayerGui. This is a simple fix, just change line 8 to:

screenGui.Parent = player.PlayerGui

Nick told you your answer, but he didn't post it as an answer, so I decided to do it.

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