Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

TextButton not responding to anything?

I'm making a game and right now I've made a TextButton of course. For some reason when I click it, it won't fire the print. Even if I hover my mouse over it won't darken as it's supposed to. I've checked my code multiple times for bugs. I've even tried remaking the script and the TextButton. Here's my code in case there are bugs.

local Button = script.Parent.TextButton

Button.MouseButton1Up:Connect(function()
	print ("Success so far!")
end)

2 comments

0

MouseButton1Up fires upon the release of the left-trigger, though it behaves similarly, the actual Signal responsible for click-detection on UI Instances, is MouseButton1Click. Ensure you're using the appropriate script (LocalScript)

0

Yes I am

2 answers

In your code, everything up to line 3 is right. Instead of writing "MouseButton1Up", try writing "MouseButton1Click" instead. Here is your edited code:

local Button = script.Parent.TextButton

Button.MouseButton1Click:Connect(function()
    print("Success so far!")
end)
-- Services
local UserInputService = game:GetService("UserInputService")
 
-- GUI Elements
-- your gui code bla bla bla
 
-- Player's Mouse
local mouse = game.Players.LocalPlayer:GetMouse()

-- Global boolean indicating whether player's MouseButton1 is down
local hold = false

function
-- code bla bla bla
if hold == false then return end
-- work off this ^
-- clode bla bla
end

also why tf do you have a space in print

4 comments

0

because you have to or else it won't work =\

0

Dramatic_Dromo is obviously not telling the truth

0

Your code is terrible as well m8 ;]

0

The Lua interpreter is whitespace insensitive. It does not matter how far the parentheses trail ahead of the function; if the context remains legitimate execution will not be affected.

This discussion is preserved as it was. New answers, comments, and votes are closed.