Button and text is not showing?

  1. What do you want to achieve? Keep it simple and clear!

So basically I want the player to go into View Mode when they press a key. Then click on the button to go back to Character Mode.

  1. What is the issue? Include screenshots / videos if possible!

there is no errors in the output I have added the debounce in the script but why sometimes it doesn’t detect the debounce and the button and text is not showing?

local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Cam = game.workspace:WaitForChild("Cam")
local CurrentCam = game.Workspace:WaitForChild("Camera")
local ShowCam = game.ReplicatedStorage:WaitForChild("ShowCamera")
local CamPosition = Vector3.new(31.726, 52.456, -52)
local LookAtPosition = Vector3.new(27.203, 45.491, -52)
local TextButton = script.Parent:WaitForChild("TextButton")
local TextLabel = script.Parent:WaitForChild("TextLabel")
local UpTown = game.Workspace:WaitForChild("Uptown")
local debounce = false


UserInputService.InputBegan:Connect(function(Input, chat)
	if Input.KeyCode == Enum.KeyCode.C and not chat then
		if debounce == false then
		debounce = true
		CurrentCam.CameraType = Enum.CameraType.Scriptable
		CurrentCam.CFrame = CFrame.lookAt(CamPosition, LookAtPosition)
		if TextLabel.Visible == false and TextButton.Visible == false then
			TextLabel.Visible = true
			TextButton.Visible = true
			TextLabel.Text = "Current Status: View Mode"
			UpTown:Play()

			TextButton.MouseButton1Click:Connect(function()
				CurrentCam.CameraType = Enum.CameraType.Custom
				CurrentCam.CameraSubject = player.Character.Humanoid
				TextLabel.Text = "Status Changed: Character Mode"
				TextButton.Visible = false
				UpTown:Stop()
				task.wait(1.1)
				TextLabel.Visible = false
				end)
			end
		end
		task.wait(5)
		debounce = false
	end
end)
1 Like

you probably set your button’s transparency into 1

my button transparency wasn’t 1 though, I set it to visible. But still I have checked the visibility of the button and make it so it shows

maybe this would work i edit it a little

local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Cam = game.workspace:WaitForChild("Cam")
local CurrentCam = game.Workspace:WaitForChild("Camera")
local ShowCam = game.ReplicatedStorage:WaitForChild("ShowCamera")
local CamPosition = Vector3.new(31.726, 52.456, -52)
local LookAtPosition = Vector3.new(27.203, 45.491, -52)
local TextButton = script.Parent:WaitForChild("TextButton")
local TextLabel = script.Parent:WaitForChild("TextLabel")
local UpTown = game.Workspace:WaitForChild("Uptown")
local debounce = false


UserInputService.InputBegan:Connect(function(Input, chat)
	if Input.KeyCode == Enum.KeyCode.C and not chat then
		if debounce == false then
		debounce = true
		CurrentCam.CameraType = Enum.CameraType.Scriptable
		CurrentCam.CFrame = CFrame.lookAt(CamPosition, LookAtPosition)
		if TextLabel.Visible == false and TextButton.Visible == false then
			TextLabel.Visible = true
			TextButton.Visible = true
			TextLabel.Text = "Current Status: View Mode"
			UpTown:Play()

			TextButton.MouseButton1Click:Connect(function()
				CurrentCam.CameraType = Enum.CameraType.Custom
				CurrentCam.CameraSubject = player.Character.Humanoid
				TextLabel.Text = "Status Changed: Character Mode"
				TextButton.Visible = false
				UpTown:Stop()
				task.wait(1.1)
				TextLabel.Visible = false
				end)
			end
		end
		task.wait(5)
		debounce = false
	end
end)

hmm… I don’t see any difference, what did you edit tho?

could you try this

local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Cam = game.workspace:WaitForChild("Cam")
local CurrentCam = game.Workspace:WaitForChild("Camera")
local ShowCam = game.ReplicatedStorage:WaitForChild("ShowCamera")
local CamPosition = Vector3.new(31.726, 52.456, -52)
local LookAtPosition = Vector3.new(27.203, 45.491, -52)
local TextButton = script.Parent:WaitForChild("TextButton")
local TextLabel = script.Parent:WaitForChild("TextLabel")
local UpTown = game.Workspace:WaitForChild("Uptown")
local debounce = false


UserInputService.InputBegan:Connect(function(Input, chat)
	if Input.KeyCode == Enum.KeyCode.C and not chat then
		if debounce == false then
		debounce = true
		CurrentCam.CameraType = Enum.CameraType.Scriptable
		CurrentCam.CFrame = CFrame.lookAt(CamPosition, LookAtPosition)
		if TextLabel.Visible == false and TextButton.Visible == false then
			TextLabel.Visible = true
			TextButton.Visible = true
			TextLabel.Text = "Current Status: View Mode"
			UpTown:Play()

			TextButton.MouseButton1Click:Wait()
			CurrentCam.CameraType = Enum.CameraType.Custom
			CurrentCam.CameraSubject = player.Character.Humanoid
			TextLabel.Text = "Status Changed: Character Mode"
			TextButton.Visible = false
			UpTown:Stop()
			task.wait(1.1)
			TextLabel.Visible = false
			end
		end
		task.wait(5)
		debounce = false
	end
end)

Hey, I have tried your code and no it still doesn’t work

1 Like

are you using this on a script? because when the text button gets clicked, only local scripts can detect when the text button is clicked , so you might need to use a remote event

I know that and im using a local script for it not a server script

When you connect an event it will still connected until you disconnect it or until an if statement prevents it to run their function, so they willl still be able to click it, since the debounce is not inside the MouseButton1Click function.

may be the button parent visible is equal to false or the parent of the button parent or the parent of that parent i think so.

If you don t understand what i said then i mean that the parent of the button visible is set to false or the parent of the button parent or other

prb when i made my first ui i have this problem too