Mastering Roblox Coding: The unofficial guide to leveling up your Roblox scripting skills and building games using Luau programming by Kiepe Mark

Mastering Roblox Coding: The unofficial guide to leveling up your Roblox scripting skills and building games using Luau programming by Kiepe Mark

Author:Kiepe, Mark [Kiepe, Mark]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2022-08-26T00:00:00+00:00


-- Checking if the user has provided feedback

if string.len(input) >= 3 then

-- Showing feedback recorded frame

givingFeedback.Visible = false

feedbackReceived.Visible = true

-- Resetting feedback textbox

textbox.Text = ""

else

warn("Cannot submit feedback less than 3

characters!")

end

end

function submitMoreFeedback()

givingFeedback.Visible = true

feedbackReceived.Visible = false

end

setup()

givingFeedback:WaitForChild("SubmitFeedback").MouseButton1Click:Connect(submitFeedback)

feedbackReceived:WaitForChild("Back").MouseButton1Click:Connect(submitMoreFeedback)

Let us take a look at the preceding local script. The setup() function simply changes the visibility of both Frames to ensure that only the GivingFeedback Frame is visible. Only having this Frame visible makes sense as we do not want to thank users for submitting their feedback without giving them the option to give feedback.

The submitFeedback() function gets executed once the .MouseButton1Click event fires on the SubmitFeedback button in our GivingFeedback Frame. Once the function starts, the user input is read by reading the .Text property. After that, we have an if statement that checks whether the string.len(input) function returns a value equal to or greater than 3 . The string.len() function returns the number of characters in a string. Therefore, the user needs to provide feedback containing at least three characters. If the user does this, the FeedbackReceived Frame will become visible, and the text in the TextBox will be set to an empty string.

Finally, we also have the submitMoreFeedback() function. This function gets executed once we click the Back button in our FeedbackReceived Frame. Once the player presses this button, the FeedbackReceived Frame becomes invisible, and the GivingFeedback Frame becomes visible again.

Obviously, our current code does not actually record the player’s feedback. The reason for this is that it is out of our current scope. If you were to actually implement this system, you could use a Webhook or use Data Stores . In Chapter 8 , Building Data Stores , we will take a look at what Datastores are and what we can do with them.

Besides this, we also use the warn() function to notify the player that their feedback needs to be at least three characters. No player will ever look in the Developer Console to see this message. It is highly recommended you make something in your GUIs that allows you to give feedback depending on the actions players of our game take. It would be a great exercise to add this yourself.

We have now seen how TextButtons elements work. Besides this, we practiced making GUIs by using: Frames , TextLabels , TextBoxes , and TextButtons elements. We have also looked at switching between two Frames by using a LocalScript . In the next section, we will look at two more GUI elements: ImageLabel and ImageButton elements.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.