Hello!
I am trying to add this, but it won’t work. I want it so that when you open a door, there is a chance that it will glitch and jumpscare you. I managed to make the door glitch randomly, but I would also like it if there was a gui that would come onto the screen to jumpscare. The problem is that this script is a server script and can’t access the player’s gui. I am stuck at this point, and would appreciate some help!
Edit: The solution might make me look really bad at scripting, and I am no expert in any way.
2 Likes
Add a remoteevent that sends client to server with the Gui as the 2nd parameter. I recommend you watch a video about remoteevents so you can better understand this script.
-- Local Script
game.ReplicatedStorage.RemoteEventName:FireServer(gui) --
-- Server Script
game.ReplicatedStorage.RemoteEventName.OnServerEvent:Connect(function(player,Gui)
-- Code here, simply set the visible or enabled property of the Gui to true.
end
Since you’re working with a server script, fire to the client and add the player who interacted with the door as the 1st parameter for the fireclient function. Then you’ll be able to send the gui to server using this method.
1 Like
you can use a remote event
with remoteEvent:FireClient(Player) --with player as parameter you can call the player to do something
then you have a local script which watches over the event and adds the Gui if the event is fired
Hopefully it helps
1 Like
Thanks for the reply! Is there any specific place I should put the local script? Thanks!
You should put the localscript in the StarterGui under your desired gui and use script.Parent to get the GUI. Also in the server script fire to the client first and then fire to the server with the GUI.
1 Like
Also, that isn’t supposed to be red, right?
The first parameter in my previous script was an example, you have to define the GUI yourself or put the localscript under the gui and use script.Parent.
1 Like
Would I need to change that on this one as well?
Nope! Since its a parameter it could be named anything. I recommend watching this video Function Parameters / Arguments - Roblox Beginner Scripting #7 - YouTube
1 Like
Okay thanks! Also do I need to just type what I want it to do under that line in the localscript?
Yes to fire to the server, then set the gui to visible on the server. Here’s a picture to explain some of the code.
Looks a little messy, but the text that looks like code is an example and won’t work depending on your GUI names.
1 Like