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

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

Asked by 8 years ago

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)
1
Ur placing the gui inside the character because when you equip it the script.Parent.Parent is the character and not the PlayerGui Nick1482 50 — 8y
1
at line 8 it should be screenGui.Parent = player.PlayerGui Nick1482 50 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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.

Ad

Answer this question