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)
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)