game.StarterGui.ScreenGui.MouseButton.MouseButton1Click:Connect(function() print("working") end)
this is a local script under a textbutton under a screen gui, but whenever i run it is ends up no printing anything, plz help!
The issue is that the contents of StarterGui are copied to the PlayerGui, and PlayerGui is what you see. You can't click a button inside StarterGui, it's just there waiting to be copied over. What you want instead is:
script.Parent.MouseButton1Click:Connect(function() print("working") end)
The LocalScript will only run once it has been copied to PlayerGui, and from there it will obtain the button correctly, using script.Parent
. Note that you could also do this:
local button = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").MouseButton button.MouseButton1Click:Connect(function() -- ... end)
StarterGui just replicates everything to the LocalPlayer.PlayerGui
So you should change everything in the PlayerGui and not StarterGui. Put your script under the ScreenGui and not under your TextButton.
script.Parent.MouseButton.MouseButton1Click:Connect(function() print("Working") end)