Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

why doesent gui work with mousebutton1click?

Asked by 5 years ago

i made a textbutton under a screengui under startergui, the textbutton had this script in it

script.Parent.MouseButton1Click:Connect(function()
    print("GUI")
end)

when this didnt work i put the screengui under a script in the workspace, this is the script

game.Players.PlayerAdded:Connect(function(player)
    local gui = script.ScreenGui:Clone()
    gui.Parent = player
    end)

and the gui doesn't even go into the player

0
for the first script use a local script not a normal script. WideSteal321 773 — 5y
0
If my answer solved your problem do not forget to hit that "Accept Answer" button. User#24403 69 — 5y
0
shouldnt ScreenGui go into the PlayerGui? GoldAngelInDisguise 297 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

For the first script, as already mentioned by WideSteal321, you should be using a LocalScript. When working with GUIs, you should be handling it locally since it is something only they should see. For that second script, you parent it to player.PlayerGui, as this is where all the contents of StarterGui get cloned into. You do not even need that second script, you can just place your ScreenGui in StarterGui, and it will get cloned into each player's PlayerGui, no need to reinvent the wheel.

Ad

Answer this question