Ahoy Everyone, here is a simple introduction to local scripts and Gui.
Local scripts are some of the most important things for scripting. Local scripts are scripts that only appear on the client there are 2 sides of Roblox the client and the server. The client is the players view so stuff like GUI. to create a local script there are a lot of way’s to put them. Here are the places
this is starter gui this is where you create gui and all of that. To insert a local script click the plus icon for starter gui then click “local script” instead of the normal “script” now that we have our first local script lets start coding in it.
local player = game.Players.LocalPlayer
what this will do is it will create a variable that is a player or also known as the player’s client. There, lets create a screen Gui now. Click the plus button on the starter GUI and click screen Gui. Now we have our first Gui, let’s create a text button click the plus button on your screen Gui then click text button. You can customize your button so lets do it.
Double click the text button so you can change your text you can also rename your text button if you would like, I named mine “clickButton” now lets create a frame you just insert a frame instead of a text button. Now lets make your frame not visible go in your properties scroll down a little and un check the visible property. Now we should see our frame is not visible anymore.
Now create a local script inside the click button. Lets write a script.
local clickButton = script.Parent
local Frame = clickButton.Parent.Frame
clickButton.MouseButton1Click:Connect(function() --mouse click event
--code goes here
end)
Now we used a event when the player clicks the button, lets make it so that our frame is visible when we click our button. So, here’s are new script
local clickButton = script.Parent
local Frame = clickButton.Parent.Frame
clickButton.MouseButton1Click:Connect(function() --mouse click event
Frame.Visible = not Frame.Visible
end)
what this local script will do is when you click the button it makes it visible again and then if you click it again then it goes back to not being visible again. Now that we’ve done a introduction to local scripts and Gui I hope you understand what they are.
You could reply and tell me what to fix on this post if I messed up anything this may not be the most in depth tutorial and local scripts and Gui.
Thanks for reading and goodbye.