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):

local RepliactedStorage = game:GetService("ReplicatedStorage")
local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")
local ClickDetector = game.Workspace.Part.ClickDetector
local Gui = game.StarterGui.ScreenGui.Frame

ClickDetector.MouseClick:Connect(function()
    print("Recived")
    ShowGUI:FireServer(Gui)
    print("Success")
end)

This basically fires the remote event when you click the part

Part 2 (Script):

local RepliactedStorage = game:GetService("ReplicatedStorage")
local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")
local Gui = game.Players.LocalPlayer.Playergui.ScreenGui.Frame

ShowGUI.OnServerEvent:Connect(function(player, gui)
    Gui.Visible = true
end)

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

Output:

05:27:55.391 - Baseplate auto-recovery file was created
  05:27:55.836 - ServerScriptService.ServerScriptShowGui:3: attempt to index nil with 'Playergui'
05:27:55.837 - Stack Begin
05:27:55.837 - Script 'ServerScriptService.ServerScriptShowGui', Line 3
05:27:55.838 - Stack End
  Recived
  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:

local RepliactedStorage = game:GetService("ReplicatedStorage")
local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")
local ClickDetector = game.Workspace.Part.ClickDetector

ClickDetector.MouseClick:Connect(function(plr)
    local gui = plr.PlayerGui.ScreenGui.Frame
    print("Recived")
    ShowGUI:FireClient(plr, gui) -- Fire the player along
    print("Success")
end)

And put this in the StarterPlayerScript, as a LocalScript.

local RepliactedStorage = game:GetService("ReplicatedStorage")
local ShowGUI = RepliactedStorage:WaitForChild("ShowGUI")

ShowGUI.OnClientEvent:Connect(function(player, gui)
    gui.Visible = true
end)
Ad

Answer this question