Why is my local script not working with a text button inside of a surface GUI?

So I have a part with a surface GUI on it and a text button inside of the surface GUI so when a player clicks the text button, it prompts a game pass purchase, the script is working but for some reason it won’t do anything when I use a local script, but without changing anything, it works in a server script (by changing the game.Players.LocalPlayer to game.Players.PlayerName). But that is ineffective and won’t work for my setup, is there a reason to why it will work in a server script but not a local script?

Hmm, well the surface Gui is in the workspace right? In that case it wouldn’t fire since a local script can’t run the workspace (because it’s being dealt with the server).
I’d recommend using the server script with:

Gui.GuiButton.MouseButton1Down:Connect(function(player)
   --function
end)

That on my POV though, you can also try to put the local script inside StarterGui, StarterPack or StarterPlayer, since those are replicated throughout the players, and those are the places where only local scripts work in.

3 Likes

After putting it in StarterPlayer, I am pleased to say it works, thanks so much for your help!

1 Like

XD that was fast.
No prob bro if anything message me. :wink:

1 Like