What's wrong with this script?

  1. What do you want to achieve?
    Make a simple game.

  2. What is the issue?
    Now, someone tried helping me (thank you) but I kept getting errors. I fixed them, but the thing that I want to work doesn’t work, here’s the script:

local Player = game:GetService(“Players”).LocalPlayer
local PlayerGui = Player.PlayerGui

local TextButton = PlayerGui:WaitForChild(“ScreenGui”):WaitForChild(“BackButton”)
local CamButton = PlayerGui.ScreenGui:WaitForChild(“CameraButton”)
local MapGui = PlayerGui.ScreenGui:WaitForChild(“ImageButton”)

function TextButtonActivated()
CamButton.Visible = true
TextButton.Visible = false
MapGui.Visible = false
function CamButtonActivated()
CamButton.Visible = false
TextButton.Visible = true
MapGui.Visible = true

TextButton.MouseButton1Click:Connect(TextButtonActivated)
CamButton.MouseButton1Click:Connect(CamButtonActivated)
end
end

  1. What solutions have you tried so far?
    I don’t know how to find this kinda of help, so I didn’t find any.

(Thanks to the person who helped me with the scripts and to anyone who is helping!)

1 Like

What do you want to achieve via this script, like what is it used for? Also try using the Lua format for scripts which is provided when you create a new thread.

local Player = game:GetService(“Players”).LocalPlayer
local PlayerGui = Player.PlayerGui

local TextButton = PlayerGui:WaitForChild(“ScreenGui”):WaitForChild(“BackButton”)
local CamButton = PlayerGui.ScreenGui:WaitForChild(“CameraButton”)
local MapGui = PlayerGui.ScreenGui:WaitForChild(“ImageButton”)

function TextButtonActivated()
CamButton.Visible = true
TextButton.Visible = false
MapGui.Visible = false
end


function CamButtonActivated()
CamButton.Visible = false
TextButton.Visible = true
MapGui.Visible = true
end

TextButton.MouseButton1Click:Connect(TextButtonActivated())
CamButton.MouseButton1Click:Connect(CamButtonActivated())

From what I could see you made a few syntactical errors.

2 Likes

Hello, I’m not sure if you know a game called FNaF, but I’m trying to make a camera system.

Also, for some reason this is the error I got:
image

It seems like the local script you are using is in the screenGUI in question. This means you could simplify your script somewhat. Other than that which line does the error direct you to when you click on it?

2 Likes

U+201c is a character called “left quotation mark”. In the script you should use the " or ’ character to make strings.

image

local ScreenGUI = script.Parent

local TextButton = ScreenGUI:WaitForChild("BackButton")
local CamButton = ScreenGUI:WaitForChild("CameraButton")
local MapGui = ScreenGUI:WaitForChild("ImageButton")

local function TextButtonActivated()
CamButton.Visible = true
TextButton.Visible = false
MapGui.Visible = false
end


local function CamButtonActivated()
CamButton.Visible = false
TextButton.Visible = true
MapGui.Visible = true
end

TextButton.MouseButton1Click:Connect(TextButtonActivated())
CamButton.MouseButton1Click:Connect(CamButtonActivated())
1 Like

Replace those quotation marks with the " character. It should work.

1 Like

Isn’t that quotation marks? On my keyboard I only have the " character.

Are you using an external text editor instead of the studio’s default one?

I just copied and pasted his original script. I made the edits and I see what you mean. Thanks for the clarification.

2 Likes

image
I edited your StarterGui into StarterGUI because you made one line of code StarterGUI while the other 2 were StarterGui.

1 Like

Ah, true. I copied and pasted your original script, must have missed that.

1 Like

But I’m still getting this error:
image

Where does the error direct you to? What kind of GUI is each? I’m assuming the the Buttons are TextButtons, but what about the MapGUI?

2 Likes

MapGui is an ImageButton,
I can’t click the error,
MapGui - ImageButton
TextButton - BackButton
CamButton - CameraButton

Not really sure why you’d want to do this but this works. I overlooked a couple of things, sorry.

local ScreenGUI = script.Parent

local TextButton = ScreenGUI:WaitForChild("BackButton")
local CamButton = ScreenGUI:WaitForChild("CameraButton")
local MapGui = ScreenGUI:WaitForChild("ImageButton")

TextButton.MouseButton1Click:Connect(function()
	CamButton.Visible = false
	TextButton.Visible = true
	MapGui.Visible = true
end)


CamButton.MouseButton1Click:Connect(function()
	CamButton.Visible = true
	TextButton.Visible = false
	MapGui.Visible = false
end)

Unless you have an alternative way of making the buttons visible again, I suggest making the process reversible.

This could be achieved like this:

local bounce = true

TextButton.MouseButton1Click:Connect(function()
	if bounce then
		bounce = false
		CamButton.Visible = false
		TextButton.Visible = true
		MapGui.Visible = true
	else
		bounce = true
		CamButton.Visible = true
		TextButton.Visible = true
		MapGui.Visible = true
	end
end)
3 Likes

Do I need to add this to the script?

local TextButton = PlayerGui:WaitForChild(“ScreenGui”):WaitForChild(“TextButton”)

local CamButton = PlayerGui.ScreenGui:WaitForChild(“CameraButton”)

local MapGui = PlayerGui.ScreenGui:WaitForChild(“ImageButton”)

I’m not sure what you mean. Just copy what I wrote exactly.

1 Like