I am creating a tool that tells you the BrickColor of any part when you hover over it with your mouse. However, I keep getting the error "Equipped is not a valid member of PlayerGui “Players.comfycouchman.PlayerGui”. I know exactly whats causing this, but I can’t think of any solutions. It’s 11:30 PM and my brain is pretty much fried lol
Heres my local script:
local screengui = script.Parent
local frame = screengui.Frame
local tool = frame.Parent.Parent
local colorImage = frame.ColorFrame.ColorImage
local colorTitle = frame.ColorTitle
local players = game:GetService("Players")
local player = players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local mouse = player:GetMouse()
local CurrentGui = nil
local ToolEquipped = false
local function SetupGui()
if CurrentGui then
CurrentGui:Destroy()
end
CurrentGui = screengui:Clone()
CurrentGui.Parent = PlayerGui
end
tool.Equipped:Connect(function()
if ToolEquipped then return end
ToolEquipped = true
mouse.Move:Connect(function()
frame.Position = UDim2.new(0, mouse.X + 25, 0, mouse.Y + 5)
frame.Visible = false
local target = mouse.Target
if target and target.Parent then
if target.Parent.ClassName == "BasePart" and target:IsAncestorOf(game.Workspace.Map) then
colorImage.BackgroundColor3 = Color3.new(target.Color)
colorTitle.Text = target.BrickColor.Name
frame.Visible = true
elseif target.Parent.ClassName == "Model" then
colorImage.BackgroundColor3 = target.Color
colorTitle.Text = target.BrickColor.Name
frame.Visible = true
end
end
SetupGui()
end)
end)
tool.Unequipped:Connect(function()
if not ToolEquipped then return end
ToolEquipped = false
if CurrentGui then
CurrentGui:Destroy()
end
CurrentGui = nil
end)