I need help with this. I cant click the button in a public server but I can in studio. I really need the gui to work for my game!
A very typical problem.
There are many reasons as to why this might happen.
Server Communications | Client Communications |
---|---|
Workspace | Workspace |
Lighting | Lighting |
Replicated Storage | Replicated Storage |
Server Storage | Replicated First |
Server Script Service | Player Gui |
Starter Pack | |
Starter Player |
1) You referenced
Server Communications
from theClient Communications
.
Workspace
and Lighting
are an exception but if you had referenced ServerStorage
or ServerScriptService
somewhere in your Local Script
, it will not work. 2)
You are waiting for something that does not even exists
.
WaitForChild()
for something that does not even exist or was removed, you script will halt and output Infinite Yield Possible
. 3) Always use
PlayerGui
over anything else.
PlayerGui
is the Local Player's
Gui
. Consider changing it to this method rather than using script.Parent
because we can't understand what its Parent
is. It could be a TextButton
, TextLabel
, Frame
and etc. You can reference a player by doing this.
-- [Declaration Section] local Player = game:GetService("Players").LocalPlayer;
and because the PlayerGui
is stored inside the Local Player
, we can look for it inside the Player
.
-- [Declaration Section] local Player = game:GetService("Players").LocalPlayer; local PlayerGui = Player:WaitForChild("PlayerGui");
[Note] WaitForChild()
for accessing PlayerGui
is crucial.
4) You used a
Server Script
for doing all this.
Server Script
for this. There is a different between Server Script
and Local Script
. Server Script
is for Server
interaction. Server Script
is the holder of all the data and uses this to keep the game going smoothly. The Local Script
is used for Client
interactions.For all the Client Communications
I mentioned above, you must be using a Local Script
and for all the Server Communications
, you must be using Server Script
.
5) You accidentally disabled the
Script
I suggest you actually put the code in your answer so we can see if it is the code's problem or something else.
Comment below when you have done so or if you have any questions. Have fun debugging.