Changing Script To Make Stuff Free On Roblox

1 Introduction 2 Author's Notes 3 Inserting a Part 4 Properties 5 Accessing a Property 6 Print 7 Variables 7.1 Instances 7.2 Integer Values 7.3 Float 7.4 Boolean 7.5 Strings 7.6 Declaring Variables 8 BrickColor and Color3 9 Vector3 10 Comments 11 Functions Welcome! If you're new to scripting.

10 min

In this guide, we’ll expand on screen images and explore how to make them into buttons that can be used for menus, in-game actions, and much more.

Button Types – Text and Image

There are two types of button objects in Roblox that can be used in your game’s UI design: TextButton|TextButtons and ImageButton|ImageButtons.

Text Button

A TextButton is very similar to a TextLabel, except that a player can activate it with a click. Internally, it also shares many of the same visual properties as a text label — font, background color, stroke color, etc.

Image Button

Similarly, an ImageButton is like an interactive version of the ImageLabel object and it uses a custom image that you upload to Roblox. It also shares most of the same properties as its non-button counterpart.

Adding Buttons to a Screen GUI

Let’s add an ImageButton to the screen and flip it between a normal appearance and a more colorful appearance when a player activates it.

  1. In the Explorer window, find the ScreenGui object.
  2. Insert an ImageButton object.

This will add an empty image button to the corner of the game view.

Upload Images

For this button, we need to upload two custom images — one for the normal appearance of the button when it’s just sitting on the screen, and a second image for when a player activates it (clicks it with their mouse, taps it when playing on their phone, or activates it with their console controller).

You can use these two menu buttons for testing — simply right-click each one and select Save Image As... to save them to a convenient location on your computer.

This time, instead of uploading an image through the Image property of the button, we’ll use the Game Explorer method. This method is useful when you want to upload more than one image at the same time.

  1. If it’s not already open, click Game Explorer from the View tab.
  1. In the window, right-click on Images and select Add Images.
  1. Find the two images on your computer, select both, and confirm that you’d like to upload them.
  2. When finished uploading, you’ll see both new images ready to use in the game!

Set the Normal Image

Setting the normal appearance for the button can be done through the button object.

  1. In the Explorer window, select the new ImageButton object.
  1. In the Image section of the Properties window, click on the Image property.
  1. In the popup window, click on the ImageButtonNormal image asset.
Changing
  1. In the Properties window, set BackgroundTransparency to a value of 1 to make the background transparent.
  1. Move the button slightly away from the corner by setting both PositionXOffset and PositionYOffset to around 30.

Attach a Local Script

The final task is to connect a function to the “activated” event of the button. This function will be used to change the appearance of the button to the brighter activated version. In an actual game, it should also be used to perform an action like opening the game’s main menu.

For this button, we’ll use a LocalScript. This is similar to the Script object which you may be familiar with, but a LocalScript is used to perform actions that only relate to a specific player and things happening on that player’s screen, such as detecting their input on the screen or displaying GUI elements (in contrast, a regular Script is used for things that occur in the overall game world and which affect all parts and players in the game).

  1. In the Explorer window, hover over the ImageButton object, click on the circle ⊕ button, and insert a LocalScript. This will create a new local script and show it.
  1. Delete any existing code, then copy and paste in these new lines:

Test the Button

With the local script in place, we can test the button’s behavior. When the game starts, the button should appear in its normal state. Click the button and its appearance should change to the brighter activated state. Another click should then return it to its normal appearance.

Troubleshooting the Button

If the button doesn't work as you expect, check the following:
  1. In addition to the ImageButtonNormal.png file, make sure you uploaded ImageButtonActivated.png.
  2. Confirm that the names of the uploaded images match the names in the script. If you uploaded image files with different names, you'll need to change the script reference names on lines 6 and 9:
    'rbxgameasset://Images/ImageButtonActivated'
    'rbxgameasset://Images/ImageButtonNormal'
  3. Make sure that your local script is a direct child of the ImageButton object.

How it Works

Let’s explore the code in the local script to understand how the button works.

  1. The first line just sets a variable button which tells the script what specific object it’s linked to. In this case it’s linked to the image button, the “parent” of the script.
  1. The second line sets a variable toggled which lets us track the current state (appearance) of the button. Because the button begins in the normal state, we set the variable’s value to false.
  1. The next block is a function that will be run when a player activates the button. Inside is a conditional statement. If the variable toggled is false(the button is off), the Image property of the button will be changed to the brighter activated image and the toggled variable will be set to true (meaning the button is on).

The fallback condition (else) will be triggered if the button is in the activated state. This condition resets the button to the normal appearance and sets toggled back to false.

  1. The final line connects the button to the function with an GuiButton/Activated|Activated event. This will make the function run whenever the button is activated.

Although there are several different event types which you can connect to buttons, the GuiButton/Activated|Activated event is the most reliable for basic buttons, providing standard button behavior on all platforms from PC to phone/tablet to console.

Great job! As you can see, creating basic buttons in Roblox can be done with either a TextButton or ImageButton object, and hooking up a local script lets you detect basic button activation as well as swap between two images.

Related Articles

Using Images in GUIs

Look out gaming world – Roblox is on a tear. Exploding in popularity over the last few years, Roblox now boasts over 64M monthly players, and is poised to overtake Minecraft as the #1 sandbox style game in the world.

While it’s fun to play other people’s games on the Roblox platform, increasing numbers of players are learning to create their own games on Roblox Studio, Roblox’s unique game engine. Developing games on Roblox is something that anyone can learn, it’s free, and in fact there have been numerous articles about even teenagers who have become millionaires making games for the Roblox marketplace.

In this blog, we are going to discuss 5 Roblox games that even complete beginners to game design and coding can make at home. As a special bonus, we’ve even included a link to our step-by-step Obby video tutorial that will teach you how to make your own custom obstacle course using Roblox Studio and the Lua programming language.

1. Obby

The first on our list of Roblox games you can make at home is an “Obby.” An Obby or Obstacle Course is a great beginner game that will teach you the basics of Roblox Studio and the Lua scripting language. An Obby presents the player with a 3D Mario style game in which the player must proceed through a series of obstacles without perishing. Obstacle courses present a number of micro-challenges that get progressively more difficult as the player advances through the course.

In an Obby you will learn how to use game elements such as Jumps, Kill blocks, Challenges, Checkpoints, and Level Advancement. In the Roblox Level editor you will need to learn about parts, scripts, materials, and transform tools in order to build a professional quality Obby.

In order to make an Obby work properly, you will need to write some scripts using the Lua scripting language. While it may seem intimidating at first, Lua is an elegant, easy-to-learn programming language, and there many tools and resources that can help you master it.

One concept that you will see in Lua while make your Obby is a conditional statement. In the example below, we tell the computer to set the player’s health to zero (thereby killing the player) if the player touches a block.

There are a number of free resources on YouTube and several tutorials on the excellent Roblox Wiki that can build your Obby-making skills.

For a Free Obby Tutorial from CodaKid, you can check out our blog tutorial here. In this tutorial we show students how to create an Obby structure, design obstacles, program kill blocks in Lua, and set up checkpoints. If you enjoy it and would like to explore CodaKid’s Roblox, Minecraft, and other game design and coding courses, you can try them for free here.

2. Adventure Game

The second on our list of Roblox games you can make at home is an Adventure Game. An Adventure Game is a story-based game with quests and items, providing the user’s character with a series of challenges to solve. Adventure Games usually feature tools, weapons, power-ups, enemies, and more. In the Roblox Editor, you will learn how to use the tool creator and the terrain editor – and you’ll also work with humanoids.

In Adventure games, one common Lua concept that you will see is a function. A function is a computing procedure or routine that contains instructions used to create the output from its input. In the example below, we are changing the players jump value to an abnormally high value of 200 (giving the player greater leaping ability) whenever the player grabs a wand.

If you are interested in step by step instructions on how to make an Adventure Map, you can try the CodaKid course for free. In the CodaKid Adventure Maps course, we show students how to design adventure tools such as lanterns, we create a Lava Shield that makes the player invulnerable to deadly lava terrain, we create a Jump Wand (illustrated above) that makes the player jump abnormally high, and we show students how to create a trophy prize that awaits all who finish your map.

3. Tycoon

The third on our list of Roblox games you can make at home is a Tycoon Game. A Tycoon is a popular business simulation game in which Roblox players build bases or factories and progressively upgrade their production facilities to earn in-game currency. The objective? To build an empire of course!

In designing your Tycoon game, you will learn about player progression, part generation, purchasing items, and about base/factory creation. In Roblox editor, common things that you’ll use are click detectors, textures and materials, humanoids, and scripts.

In building your Tycoon game, you will use a slightly more complex function than the grabWand function illustrated above. In the example below, the function spawnCash () will create a cash payout when the Cash button is clicked.

There are several free Roblox Tycoon tutorials on the web that can get you started. If you’d like to take your Tycoon Game to the next level, CodaKid offers affordable online courses that will teach you how to design tycoon factories, program the automation and factory machinery, create and program automated droppers that create cash blocks that the player uses to purchase more advanced factory pieces, and more.

Changing Script To Make Stuff Free On Roblox No Hack

4. Racing Game

Roblox Free Stuff In Games

The fourth on our list of Roblox games you can make at home is a Racing Game. Roblox racing games involve racing cars or other vehicles against others to see who can reach the finish line first. Racing games are multi-player affairs, and to create a good one you’ll need to learn how to program in Lua.

When designing your racing game you will use game elements such as cards, checkpoints, timers, obstacles, and leaderboards. In the Roblox Editor you’ll likely use vehicle seats, the terrain editor, server scripts, the Roblox toolbox, and more.

When building your Roblox racing game, one Lua coding concept that you’ll use is a loop with a timer to track how long the player has been racing. In this code snippet, Lua checks to see if a condition is true (if player.raceStarted.Value) and it progressively adds 1 second the timer.

In CodaKid’s Racing Course Tutorial we create our own cards, program a timer, set up a leaderboard system, and set ordered checkpoints that players must follow to win the race.

5. Infinite Runner

The fifth game on our list of Roblox games you can make at home is the Infinite Runner. Infinite Runner games are games in which the objective is to dodge obstacles and stay alive the longest.

When design your Roblox Infinite Runner game, you design with hazards, timers, terrain, and leaderboards. Things you’ll likely use in Roblox Editor include the Terrain Generator, Lighting, and Fog. 3D Infinite Runner games are always more fun in multiplayer, so you’ll further develop your skills with ServerScripts which will allow you to play your game with friends and family.

When making your Infinite Runner game, one Lua coding concept that you’ll likely use is a Nested Loop to generate terrain. In this example, we show an example nested For Loops someone might use to generate terrain.

In CodaKid’s Infinite Runner course, we teach you how to program and generate terrain, use kill blocks, use timers, set up leaderboards, and create a super fun multiplayer experience.

Changing Script To Make Stuff Free On Roblox Pastebin

If you would like step by step instruction on how to make games for Roblox, we encourage you to try CodaKid’s Game Development with Roblox series for free. All CodaKid courses are self-paced, but also include messaging and screen share support with our team of friendly teachers. CodaKid’s courses all come with a free trial and feature affordable monthly subscriptions that can be cancelled anytime.

Free Items Script Roblox

Are there any Roblox games that you think we should add to our list? Please leave your ideas in the comments below!

Share the post '5 Awesome Roblox Games You Can Make At Home'