Local scripts are not working for my surface Gui interface

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! I want to transfar all my server scripts into local scripts and have them work

  2. What is the issue? Include screenshots / videos if possible! Only server scripts are working in my surface gui local scripts do not work

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? changed all my scripts to local script and then reverted them because they where not working

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

   local Frame = script.Parent.SurfaceGui
local CurrentFrame = nil

for _, button in pairs(Frame:GetChildren()) do
	if button:IsA("TextButton") then
			local relatedFrame = nil
			for _, frame in ipairs(Frame:GetChildren()) do
				if frame:IsA("Frame") then
					if frame.Name == button.Name then
						relatedFrame = frame

			if relatedFrame then
				if relatedFrame == CurrentFrame then
					CurrentFrame.Visible = false
					CurrentFrame = nil
				elseif CurrentFrame then
					CurrentFrame.Visible = false
					CurrentFrame = relatedFrame
					CurrentFrame.Visible = true
					CurrentFrame = relatedFrame
					CurrentFrame.Visible = true
end              all the scripts in my gui are not working if they are local

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

A LocalScript | Roblox Creator Documentation does not work in Workspace | Roblox Creator Documentation

A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service

So you should put the local script in PlayerGui | Roblox Creator Documentation / PlayerScripts | Roblox Creator Documentation which is automatically done so if you put the local script in Roblox Creator Documentation or StarterPlayerScripts | Roblox Creator Documentation . Then change
local Frame = script.Parent.SurfaceGui to whereever the SurfaceGui | Roblox Creator Documentation is in your Workspace | Roblox Creator Documentation.