"Script.Parent" is trying to find a Value name, but not a value

I have a problem with my script:

posBack1 is not a valid member of Folder “Players.Mixmaxed.PlayerGui.ScreenGui.Frame.Map.Positions”

I think, when i try to use “Script.Parent.Parent.Positions.posBack1”, it’s trying to find “posBack1”, but not getting “posBack1” value. How can i solve this problem? Thanks for any help.

script.Parent.MouseButton1Click:Connect(function()
	local position1 = script.Parent.PositionA.Value - 1
	local position2 = script.Parent.PositionA.Value - 2
	local position3 = script.Parent.PositionA.Value + 1
	local position4 = script.Parent.PositionA.Value + 2
	
	local posBack1 = "P" .. position1
	local posBack2 = "P" .. position2
	local posNew1 = "P" .. position3
	local powNew2 = "P" .. position4
	
	script.Parent.Parent.Positions.posBack1.Visible = true -- Problem here
	script.Parent.Parent.Positions.posBack2.Visible = true
	script.Parent.Parent.Positions.posBack3.Visible = true
	script.Parent.Parent.Positions.posBack4.Visible = true
end)
1 Like

Does the script work fine, nevertheless? Roblox has neem acting up recently, and I am getting the same error as you do, but my script works just fine.

1 Like

Yes, it works, I used the print command which gave me the correct value.

Can you please show structure of your ScreenGui?

Hm, what about Positions folder structure?

Well, issue is you are trying to access Instance by using Variable name, but instead it attempts to access Instance with your variable name, so you need to use [Variable] so it would use value of Variable, instead of variable name.

Fixed code.

script.Parent.MouseButton1Click:Connect(function()
local position1 = script.Parent.PositionA.Value - 1
local position2 = script.Parent.PositionA.Value - 2
local position3 = script.Parent.PositionA.Value + 1
local position4 = script.Parent.PositionA.Value + 2

local posBack1 = "P" .. position1
local posBack2 = "P" .. position2
local posNew1 = "P" .. position3
local powNew2 = "P" .. position4

script.Parent.Parent.Positions[posBack1].Visible = true
script.Parent.Parent.Positions[posBack2].Visible = true
script.Parent.Parent.Positions[posNew1].Visible = true
script.Parent.Parent.Positions[powNew2].Visible = true
end)
1 Like

Thanks for help! It’s worked fine!