Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why isn't my script working?

Asked by 7 years ago
Edited 7 years ago

I am basically trying to script a GUI control panel that allows users to accelerate the train with a power lever (in the GUI) and a reverser (Forward, Neutral, Reverse)

I've scripted the entire thing but it does not seem to function as the script is supposed to. The GUI appears on the screen but when pressed it does nothing. It's a medium sized script so its a bit hard to explain each function.

Since it would be a bit too large and annoying here, I put the script in a PasteBin - http://pastebin.com/raw/64jJ1hgp

Here's are all the objects in the Workspace that is mentioned and relevant to the script: https://s31.postimg.org/4hd2up2ij/Screen_Shot_2016_06_24_at_11_15_21_AM.png

What are the errors in the script that is not allowing the GUI (or the script) to function as its scripted to?

(I apologize for the long script and thank you for your help in advanced)

1 answer

Log in to vote
0
Answered by 7 years ago

hi, your script appears to be okay but you're underestimating the way GUI's work on Roblox.

Roblox' GUI's are always on client, in fact you can find them in the user's PlayerGui. I can see in your script that you parent the gui to the PlayerGui just fine. However, when you have parented it this way you can't refer to it anymore as if it is script.Parent.Bottom!

Best practice is to put a localscript inside the gui that will handle all the interaction with the client. This will also remove any connection lag so your players will have a more fluid experience.

This does mean you will have to communicate to the server via remote events, you can find more info about those here: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial (look at server events)

ps: a quick hack if you're not using FilteringEnabled is to just make sure your serversided script knows where the GUI is in the playergui. Put the code for the GUI in your method for finding the player who jumped in the seat and make sure the gui's parent is the player's PlayerGui.

ps ps: the ps solution is bad for several reasons that i won't go into here. you should really try to figure out server client communication! it's useful knowledge inside and outside roblox.

0
Okay, I see what youre saying but I'm still a bit confused. Do I make the script (the original one) into a LocalScript? "script.Parent.Bottom" is only referred in the very first line, what do you mean by it can't be referred to anymore? (Where do you see that?) Where exaclty inside the GUI (Bottom) do I put the localscript? Lastly for the communication to the server via remote events (in the local scripthelpersorg 10 — 7y
0
(Cont.) Lastly for the communication to the server via remote events (in the local scripts), what are the events that are getting fired? When the buttons on the GUI are pressed? scripthelpersorg 10 — 7y
Ad

Answer this question