What is the issue?
I am trying to make so when you press a text button a new one appears saying “Camera” instead of “Back” (it got destroyed when I clicked it) and when I click “Camera” text button, the image button and other text buttons appear again, but “Camera” text button gets destroyed and “Back” one appears again, so basically a loop.
Here is my script:
local Camera = game.StarterGui.ScreenGui.BackButton
local Clone = Camera:Clone()
if Camera then
wait(0.1)
game.StarterGui.ScreenGui.BackButton:Destroy()
Clone:Clone().Parent = game.StarterGui.ScreenGui.BackButton.LocalScript
Clone:Clone().Parent.Name = “CameraButton”
Button.MouseButton1Click:Connect(function()
ImageButton.Visible = true
end)
end
What solutions have you tried so far?
Now, because barely anyone makes FNaF games on roblox (not the RP ones),
there are no posts helping me.
Well you did a mistake everything you wrote could have ran so on to the mistake: StarterGui is replicated or placed in PlayerGui when game starts so that’s not gonna work out sadly
You should use PlayerGui instead add this to 1st line:
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
Why are you destroying the back button? No need to do that. Just change its visibility. You can easily make a new button appear by manipulating the items visibility.
game.PlayerGui isn’t a thing and that would error.
You would have 2 events, one for the camera button, one for the text button, you would toggle them to visible/invisible, along with a function running.
local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player.PlayerGui
local TextButton = PlayerGui:WaitForChild("ScreenGui"):WaitForChild("TextButton")
local CamButton = PlayerGui.ScreenGui:WaitForChild("CameraButton")
function TextButtonActivated()
CamButton.Visible = true
TextButton.Visible = false
--do stuff u want to do when the text button gets clicked
end
function CamButtonActivated()
CamButton.Visible = false
TextButton.Visible = true
--Make the other buttons visible too
--do stuff u want to do when the cam button gets clicked
end
TextButton.MouseButton1Click:Connect(TextButtonActivated)
CamButton.MouseButton1Click:Connect(CamButtonActivated)
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”)