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

Trying to make a GUI pop up from a part but wont work??

Asked by
hoth7 45
4 years ago

So, currently, I am trying to make it so whenever you click a click detector, it makes a GUI pop up. Can you try to help me?

Part 1 (Local Script):

01local RepliactedStorage = game:GetService("ReplicatedStorage")
02local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")
03local ClickDetector = game.Workspace.Part.ClickDetector
04local Gui = game.StarterGui.ScreenGui.Frame
05 
06ClickDetector.MouseClick:Connect(function()
07    print("Recived")
08    ShowGUI:FireServer(Gui)
09    print("Success")
10end)

This basically fires the remote event when you click the part

Part 2 (Script):

1local RepliactedStorage = game:GetService("ReplicatedStorage")
2local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")
3local Gui = game.Players.LocalPlayer.Playergui.ScreenGui.Frame
4 
5ShowGUI.OnServerEvent:Connect(function(player, gui)
6    Gui.Visible = true
7end)

This script activates when the remote event is fired, and tries to make the GUI visible but doesn't work? Help me, please!

Output:

105:27:55.391 - Baseplate auto-recovery file was created
2  05:27:55.836 - ServerScriptService.ServerScriptShowGui:3: attempt to index nil with 'Playergui'
305:27:55.837 - Stack Begin
405:27:55.837 - Script 'ServerScriptService.ServerScriptShowGui', Line 3
505:27:55.838 - Stack End
6  Recived
7  Success
0
I’m just going to say this right now, you went way to far. It’s simple but you made it hard, I can solve it but you are going to have to wait a couple of hours till I can get to my computer and test out the script for you. HissingSoldier 0 — 4y
0
Ok hoth7 45 — 4y
0
U can do everything locally IcyMizu 122 — 4y
0
No need for the remote event IcyMizu 122 — 4y
View all comments (2 more)
0
Firing an event isn't necessary here since you are not trying to get a client to talk to the server, instead you could have it all done in the LocalScript AntoninFearless 622 — 4y
0
I know I could've, this was just to mess with RemoteEvents since I'm just learning them. And they are extremely valuable. hoth7 45 — 4y

1 answer

Log in to vote
1
Answered by
Techyfied 114
4 years ago
Edited 4 years ago

Instead of firing client to server, you'll need to fire server to client. So, the part 1 script should be a Script and this is what it should be:

01local RepliactedStorage = game:GetService("ReplicatedStorage")
02local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")
03local ClickDetector = game.Workspace.Part.ClickDetector
04 
05ClickDetector.MouseClick:Connect(function(plr)
06    local gui = plr.PlayerGui.ScreenGui.Frame
07    print("Recived")
08    ShowGUI:FireClient(plr, gui) -- Fire the player along
09    print("Success")
10end)

And put this in the StarterPlayerScript, as a LocalScript.

1local RepliactedStorage = game:GetService("ReplicatedStorage")
2local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")
3 
4ShowGUI.OnClientEvent:Connect(function(player, gui)
5    gui.Visible = true
6end)
Ad

Answer this question