I’m not really that good with FE, I’m still learning, so excuse me if I get anything wrong here or if I’m mistaken.
I’ve come across this frustrating error that I couldn’t find a solution for it.
I’m trying to detect the “MainUI” from the Player’s PlayerGui when they equip, activate or unequip their gun, but it kept throwing me this error. It works fine in studio, but not in a Roblox server.
GUIs from StarterPack are instantiated at the client and thus do not exist for the server when FE is enabled in a live game. Testing it in studio works because in a local server the client and server are the same.
The gui I’m trying to get isn’t given from the tool when equipped. It’s already in the StarterGui and it gives it out when the player joins. And to avoid the pain of re-setting the changes of the texts, frames, etc. - I disabled “ResetOnSpawn”. The ammo frame is in the “MainUI” that will be given to the player once they join the game.
Use a remote (in replicated storage for instance) that both the client and the server have access to, then have the server request changes to the client via it.
From the first image you posted, I also noticed that you are also trying to get the mouse of the player on the server script.
This will not work. You should instead use a combination of a local script, a server script, and some remotes when making the gun. The LocalScript should be responsible for updating the UI and for sending mouse clicks, mouse position, and etc to the server, and the Script should be responsible for actually shooting the gun through the input received from the LocalScript.
By splitting the workload between the client and the server, you will be able to access the GUI from the LocalScript.
Ultimately, if you are working with FE/experimental mode off, then you will need to use RemoteEvents.
I was really lazy to make RemoteEvents and go through all that, so I decided to use one script and make it server-side. That worked with me before but not this time. I guess I have to re-code it and this time use RemoteEvents + LocalScript. ¯_(ツ)_/¯
Create a google document, and just save everything to it. For instance, I have a google doc, so when I need to use remote events in my code, I can copy and paste them (the events are always in the same place, including the same names.) Makes life oh so much easy.
If I remember correctly, you can actually grab the mouse from the server and it works, however in saying that I’d not recommend it at all and it seems completely dodgy and unreliable.
How would that even work though? Surely the mouse is solely available to the client using the mouse, so unless filtering-enabled is turned off, the server wouldn’t have access to the client’s mouse. Also, the wiki says itself the mouse can only be accessed by a local script.
You can’t get “not a valid member” errors from WaitForChild. You must still have had a .Something index or a FindFirstChild somewhere that was erroring.
Nope. It was that specific line (and another line that had the same line of code). Even if I don’t add WaitForChild, it still behaved the same and returned the same error.
Are those ‘PlayAnimation’ and ‘StopAnimation’ remote events for running AnimationTracks?
If they are, you don’t need the server’s assistance in doing so. Your client can run animations on your own character, and it will replicate to other clients.