I recently turned on FE and it broke this script. I'm trying to have it copy 'TheMenu' from serverstorage to player gui when I click a startergui button. I know it needs a remote event but I'm not sure where or how to use it.
1 | function click() |
2 | local player = script.Parent.Parent.Parent.Parent |
3 |
4 | game.ServerStorage.GUI.TheMenu:clone().Parent = player.PlayerGui |
5 |
6 | end |
7 | script.Parent.MouseButton 1 Down:connect(click) |
The hierarchy of the script is script -> text button -> screen gui -> starter gui
I know someone else asked something similar but the answer wasn't too helpful to this script.
Ayee there, use a server script to clone GUIs or anything else from the serverstorage since clients can't access it.
Also make a remote event in the replicated storage for this to work~
This is one way you can do it :
|Client|
1 | local ShowGui = game.ReplicatedStorage.RemoteEvent |
2 |
3 | script.Parent.Parent.Parent.MouseButton 1 Click:connect( function () |
4 | ShowGui:FireServer() |
5 | end ) |
|Server|
1 | local ShowGui = game:GetService( "ReplicatedStorage" ).RemoteEvent |
2 |
3 | ShowGui.OnServerEvent:connect( function (player) |
4 | game.ServerStorage.GUI.TheMenu:Clone().Parent = player:WaitForChild( "PlayerGui" ) |
5 | or game.ServerStorage.GUI.TheMenu:Clone().Parent = player:FindFirstChild( "PlayerGui" ) |
6 | end ) |
Hope this helps!, please respond if this works.
Here is the answer probably :connect()and :clone() is depricated Use :Connect and :Clone() instead And also use a local script instead of a global script
1 | function click() |
2 | local player = game.Players.LocalPlayer |
3 |
4 | game.ServerStorage.GUI.TheMenu:Clone().Parent = player:WaitForChild( "PlayerGui" ) |
5 |
6 | end |
7 | script.Parent.MouseButton 1 Down:Connect(click) |
I always recommend using local scripts if you are using it under StarterGui, StarterPack and StarterPlayer Please submit this answer if it worked!