Hello. Basically I have a localscript here, in a textbutton, which when clicked, should make everything described Visible = false and Visible = true if its false already. The thing is that for some reason the script thinks that Value "On" doesnt exist or something like that. heres the code:

local pipp = game.Players.LocalPlayer
local Mouse = pipp:GetMouse()
local button = script.Parent
local on = script.Parent.Parent:FindFirstChild("On")
local mnscreen = script.Parent.Parent.MainScreen
local invGUI = script.Parent.Parent
local box1 = invGUI:findFirstChild("Box1")
local box2 = invGUI:findFirstChild("Box2")
local box3 = invGUI:findFirstChild("Box3")
local box4 = invGUI:findFirstChild("Box4")
local box5 = invGUI:findFirstChild("Box5")
local box6 = invGUI:findFirstChild("Box6")
local box7 = invGUI:findFirstChild("Box7")
local box8 = invGUI:findFirstChild("Box8")
local dropbutton = invGUI:findFirstChild("Drop")

button.MouseButton1Down:connect(function(key)
	if script.Parent then
		if on.Value == true then
			mnscreen.Visible = false
			box1.Visible = false
			box2.Visible = false
			box3.Visible = false
			box4.Visible = false
			box5.Visible = false
			box6.Visible = false
			box7.Visible = false
			box8.Visible = false
			dropbutton.Visible = false
			on.Value = false
		elseif on.Value == false then
			mnscreen.Visible = true
			box1.Visible = true
			box2.Visible = true
			box3.Visible = true
			box4.Visible = true
			box5.Visible = true
			box6.Visible = true
			box7.Visible = true
			box8.Visible = true	
			dropbutton.Visible = true
			on.Value = true		
		end
	end
end)


I get an output: attempt to index upvalue 'on' (a nil value)

I changed the on variable to be found using findFirstChild(), still doesnt work. (Was just script.Parent.Parent.On before). And sorry for my stupid code, i've written this before i even knew that i wouldn't need to specify every GUI part if i have put everything in one frame or something.

Feel free to ask any questions. Thank you for any answers

EDIT: Forgot to mention that everything works on playtesting, only getting this error on server.