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