What do you want to achieve? Keep it simple and clear!
I’m currently writing / setting up a way to edit the color of an OverheadGui for titles above a player.
What is the issue? Include screenshots / videos if possible!
Whenever I try to select a color, it’ll say it can’t find it within the head of the player, but with the path I wrote, and where it’s located…it shouldn’t be looking at the head.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve been asking around and I’ve been told my path is correct, but it’s still returning an error.
Your OverheadGui seems to be inside the character, not the head itself. Try parenting the OverheadGui to the Head and trying again. Alternatively, it could be that you are trying to access the Gui without it being loaded yet.
Yes, I adorneed the overheadgui to the character instead of it being at the head so it remains stable as you walk around and whatnot.
What should I do if it’s just being accessed before loading?
-The overheadgui being within the character is intentional, i’m just not sure why it keeps searching the head for it when the path I wrote isn’t trying to find it there.
Your error is searching for the GUI inside the player’s head. Maybe that is the issue. Try checking your ColorPicker script inside the ColorPicker GUI in StarterGuis.
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local changeColor = game:GetService("ReplicatedStorage").Remotes.ChangeHeaderColor
local mainFrame = script.Parent.MainFrame
local pickerArea = mainFrame.PickerArea
local pointer = mainFrame.PickerArea.Pointer
local gradient = pickerArea:FindFirstChildOfClass("UIGradient")
local ColorKeyPoints = gradient.Color.Keypoints
local minXPos = pickerArea.AbsolutePosition.X -- left cord
local maxXPos = minXPos + pickerArea.AbsoluteSize.X -- right cord
local pxSize_x = maxXPos - minXPos -- width of the whole area
local lastUpdated = 0
local selecting = false
local function beginSelection()
selecting = true
local mouseX, percentage, color
local _low, _high, _localPct
repeat RunService.Heartbeat:Wait()
mouseX = UIS:GetMouseLocation().X -- raw mouse position
if (mouseX < minXPos) then
mouseX = minXPos
elseif (mouseX > maxXPos) then
mouseX = maxXPos
end
percentage = (mouseX - minXPos)/pxSize_x -- gradient percentage
pointer.Position = UDim2.new(percentage,0,0,0)
if (percentage < 0 or percentage > 1) then continue; end
_low = ColorKeyPoints[1]; _high = ColorKeyPoints[#ColorKeyPoints]
for i = 1, #ColorKeyPoints do
-- The following line is temporary. This can be done a little better.
if (i + 1 > #ColorKeyPoints) then continue; end
if (ColorKeyPoints[i].Time <= percentage and ColorKeyPoints[i+1].Time >= percentage) then
_low = ColorKeyPoints[i]; _high = ColorKeyPoints[i+1]
_localPct = (percentage - _low.Time)/(_high.Time - _low.Time)
color = _low.Value:Lerp(_high.Value, _localPct)
Players.LocalPlayer.Character:FindFirstChild("OverheadGui").Label.TextColor = BrickColor.new(color)
Players.LocalPlayer.Character:FindFirstChild("OverheadGui").Label3.TextColor = BrickColor.new(color)
end
end
until not selecting
wait(.6)
changeColor:FireServer(color)
end
I went through it and added a FindFirstChild (Even with WaitForChild(), it returns the same error), hoping it would just not look at the head but it’s still sending the error where it’s looking at the head. Unless i’m overlooking something, anyways.
FindFirstChild() won’t do much in your case since it isn’t reading it anyways. WaitForChild() makes it wait a little before continuing, hence why I wanted you to use that. In the error message, it says Line 70. Not sure if you got something there. It seems like for some reason it isn’t reading the Gui. Also, I recommend you first wait for the character as there is a chance that the character might not exist before searching it. This can be done by saying local Character = Players.LocalPlayer.Character or Players.LocalPlayer.Character:Wait() (that used to work, not sure if it still works). Other than that, I really have no idea what else could be causing this.
pickerArea.InputBegan:Connect(function(input)
if
(input.UserInputType == Enum.UserInputType.MouseButton1 or
input.UserInputType == Enum.UserInputType.Touch)
then beginSelection() end
end)
pickerArea.InputEnded:Connect(function(input)
if
(input.UserInputType == Enum.UserInputType.MouseButton1 or
input.UserInputType == Enum.UserInputType.Touch)
then selecting = false
end
end)
Try using the debugger or something to see where it errors and why it is searching in the head. Also, attempt to use the finder Ctrl + F and search for .Head or just Head to see if you find it anywhere. There is also the possibility that a similar script is running the code and you are just searching in the wrong one. Either way, if it is searching in the head, then somewhere, you have specified for it to search in the head.
Alright…so when I just move the GUI to the StarterGUI, it works…flawlessly. But when I move it back to where it belongs it keeps searching for the head. …What?
Is the local script inside the Overhead UI by any chance? If so, LocalScripts don’t run in the workspace, so any changes made to the Overhead UI within the scripts of the Overhead UI would not work. I am unsure of what is happening, but try to figure out why this is.
Alright so, still haven’t found where exactly went wrong, but we’re making progress.
changeColor.OnServerEvent:Connect(function(player, color3)
local rank = player:GetRankInGroup(Configurations.GROUP_ID)
local rank1 = (rank == 253)
local module = DataModule.OwnedGamepasses[player.UserId]
if (not module or not module[Configurations.ColoredTitles] or not rank1) then return; end
if (os.clock() - (changeCoolDown[player.UserId] or 0) > .4) then
changeCoolDown[player.UserId] = os.clock()
local Character = player.Character or player.CharacterAdded:Wait()
Character:FindFirstChild("OverheadGui").Label.TextColor = BrickColor.new(color3)
Character:FindFirstChild("OverheadGui").Label3.TextColor = BrickColor.new(color3)
end
end)
What’s going on is that it’s not actually sending the GUI to the player’s screen, but it should work properly, I think.