Mousebutton Not working

Hello Roblox Developers,

For some reason, my GUI button is not clicking correctly. Now, the frame this mousebutton is in is having it’s parent changed when the play button is clicked. Also note, the script is inside of the button.
Any fixes?

 local playername = script.Parent.Parent.playerusername.Value
local player = game.Players:FindFirstChild(playername)

if player then
	print("Found " .. playername)
end

local promptauth = player:FindFirstChild("promptauth")

if promptauth then
	print("Found PromptAuth for " .. playername)
else
	print("Failed to find PromptAuth for " .. playername)
end

-- This is the part where its bugged
script.Parent.MouseButton1Click:Connect(function()
	print("button click")
end)


What type of script is it because i don’t think normal scripts work in the startergui

1 Like

Parent changing on play is probably a plugin. Also, make sure thats a local script

No, its not. I intend it for the parent to be changed for it to be duplicated into a list.

I intend it to be a script so the value “promptauth” can be changed to true, which has to be serversided. Do I have to fire a remoteevent to do this?

can you please post a screenshot of the explorer?
if it possible show whole ReplicatedStorage,StarterGui(with screenGuis),parents and childs of the script you are using

May you a post a screenshot ?. However, I can provide some troubleshooting steps you can take:

  1. Make sure the script is attached to the correct GUI button. Double-check that the script is attached to the button you’re trying to click.

  2. Check the output console for any error messages. If there are any errors, they will be displayed in the output console. Fix any errors that are displayed and try clicking the button again.

  3. Check if the script is running at all. Add a print statement at the beginning of the script to see if it’s running at all. If you don’t see the print statement in the output console, then the script may not be running.

  4. Try using InputBegan instead of MouseButton1Click. If the button is not registering clicks, you can try using the InputBegan event instead. This event fires whenever the button is pressed, regardless of whether it was clicked or touched.

  5. Check if the button is enabled. Make sure that the button is not disabled or invisible, as this will prevent it from being clicked.

  6. Check if there are any other scripts that could be interfering. If there are other scripts attached to the button or its parent frames, they could be interfering with the button’s click event.

Nah you can use normal scripts inside starter GUI, it’s just less common to use it. For example, an admin panel will most likely use a server script.

so im lost at the:

local playername = script.Parent.Parent.playerusername.Value

part. if this is the case, it wont even make it out of screenGUI. Can we have a picture of your explorer?

I personally do not use MouseButton1Click, I use MouseButton1Click or script.Parent.Activated. These work for me all the time. That might be your issue. try using MouseButton1Click or script.Parent.Activated instead :slight_smile: