I've tried practically everything to fix this, but I can't seem to get it working. I want to have a book-style GUI (done via RoDocker) become visible for the player who clicked on a model in my game. However, while the ClickDetector works, the scripts don't seem to and the GUI never becomes visible.
I'm doing this via a RemoteEvent. I want the ClickDetector to fire the RemoteEvent so the Client side knows to make the GUI visible. I've tried more than just this method, but nothing seems to be working. My question is a lot similar to this one from 2020 on the Dev Forum, but it was never solved and I really don't want to make the book a tool.
I'm autistic and rather new to Lua (with some knowledge in other languages), so please be patient with me. I'll need a lot of help.
Here are the placements of my scripts:
https://i.imgur.com/vW27kLe.png (My ClickDetector in its parent model, with its script to tell the RemoteEvent to fire)
https://i.imgur.com/qwJ09Bz.png (My RemoteEvent in ReplicatedStorage)
https://i.imgur.com/SoFMCzS.png (My script to tell the GUI to become visible "MakeVisible" in the GUI I want to make visible, note how RoDocker handles book GUIs via placing multiple frames into one ScreenGui)
My scripts so far are below. I've changed these so many times to try to get these to work, so they may look wonky from all the things I ended up trying.
Script telling RemoteEvent to fire (DinosaurBookOpen):
local clickDetector = workspace.DinosaurClickDetector local remoteEvent = ReplicatedStorage:WaitForChild("DinosaurBook") local function onClicked(player) remoteEvent:FireClient(player) end -- Connect the function to the MouseClick event clickDetector.MouseClick:Connect(onClicked)
Script receiving RemoteEvent and telling GUI to becoming visible (MakeVisible):
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("DinosaurBook") local function onNotifyPlayer() script.Parent.Visible == true end) remoteEvent.OnClientEvent:Connect(onNotifyPlayer)
You're not getting the ClickDetector
correctly on line 1. It's not located directly under Workspace, it's parented to "dinosaur book", as you show in your first image.
I would suggest not to use any blankspaces in names of Instances, but it does work if you want to keep it. You could do this:
local clickDetector = workspace["dinosaur book"].DinosaurClickDetector
Although I would suggest you to get the ClickDetector
by doing like this:
local clickDetector = script.Parent
About your second variable, on your third line, you are writing "ReplicatedStorage" without first declaring a variable with that name. You need to create that variable before. As you do in your second script;
local ReplicatedStorage = game:GetService("ReplicatedStorage")
That should be all the errors that I can see, however just to be certain, even though you have it correct on your images; Make sure your first script, the one that gets the Click, is a Server Script (normal Script
). And that your second script, which sets the Frame Gui to Visible, is a Local Script (LocalScript
).
Alright, with my scripts now fixed, I might have run into an engine bug, because now it appears that while the GUI's visibility becomes true for the player, it doesn't actually appear.
See that the book GUI's Visible property is checked while I'm playing: https://i.imgur.com/0PZs2Bh.png
And BookRenderer is enabled, as it should be in RoDocker's case: https://i.imgur.com/JDMR5Za.png
I'm stumped! As you can see in my first image, it doesn't appear on the player's screen. Thanks for the help, either way.