Answered by
8 years ago Edited 8 years ago
This is a Common Mistake
You actually want the PlayerGui
, not the StarterGui
service.
01 | local plr = game.Players.LocalPlayer |
02 | local plrGui = plr:WaitForChild( "PlayerGui" ) |
03 | local screenGui = plrGui:WaitForChild( "ScreenGui" ) |
05 | if script.Parent.Equipped = = true then |
06 | screenGui.Enabled = true |
09 | if script.Parent.Unequipped = = false then |
10 | screenGui.Enabled = false |
Next, this isn't connected to any event, so it'll only fire once, and never update. To fix this, lets use some events.
01 | local plr = game.Players.LocalPlayer |
02 | local plrGui = plr:WaitForChild( "PlayerGui" ) |
03 | local screenGui = plrGui:WaitForChild( "ScreenGui" ) |
05 | local tool = script.Parent |
07 | tool.Equipped:Connect( function () |
08 | screenGui.Enabled = true |
09 | tool.Unequipped:Wait() |
10 | screenGui.Enabled = false |