Attempt to index boolean with 'Value'

I have a string value telling me the name of the model of a viewportframe model. But the string value won’t work and it just gives me an error saying " attempt to index boolean with ‘Value’ "

Here is the script

local CharacterOnScreen = gui.CharacterName -- a string value
local gui = script.Parent 
local characters = gui.Characters -- folder

local function SetCharacter()
	characters:FindFirstChild("Rig").Parent = gui.Selected1.WorldModel
	characters:FindFirstChild("Rig2").Parent = gui.Selected2.WorldModel
	characters:FindFirstChild("Rig3").Parent = gui.Selected3.WorldModel
	CharacterOnScreen.Value = gui.Selected2.WorldModel:FindFirstChildWhichIsA("Model").Name -- where the error comes from
end

if you need more context, i can give them to you

Well you are referincing gui.CharacterName before referencing gui. Let’s start with that.

local gui = script.Parent
local CharacterOnScreen = gui.CharacterName

Make sure that you are not changing the variable CharacterOnScreen, you can do this by searching with CTRL + F.

You are probably setting this value directly instead of setting the .Value property.

1 Like