House System Tutorial! - Roblox (Object Oriented Ownership)
okeanskiy okeanskiy
16K subscribers
47,342 views
1.2K

 Published On Mar 11, 2020

Join my Discord Server and talk to me!   / discord  
TIMESTAMPS: 0:27 Workspace Setup
3:39 Server Script and House Object Script
11:05 House:update()
15:07 Player Leave Event
18:15 House:ownsHouse()
21:00 Teleport Home GUI

Take the basics of object oriented programming in roblox lua to make a simple house system. This system allows players to walk up to a house and “claim” it by touching the button. A player can only own one house, and the house becomes unclaimed when the player leaves, so it can be claimed again by someone else. There is also a teleport gui for players to quickly get back to their respective residence.

Object oriented programming is all about organizing code into “objects”, in this case we have a server script that creates a bunch of “House” objects and stores them inside a table, and gives them the instruction to update every second. Every “object” has its own set of “properties” and “methods”. In this case, our house objects have properties to store the player that owns the house, the teleport part, the claim part, and a table reference to all the other houses in our game. The methods of our house objects are functions like :ownsHouse(player), to tell if a player owns a house already, and :teleportOwner(), to teleport the owner of a house to its teleport part.

Essentially, our House object script/module acts as a blueprint to handle House-related code that would otherwise be repeated. This keeps code organized and tidy. The actual server script only ends up being a minimal 13 lines long.

DOWNLOADS:
Classic OOP Module by rxi: https://www.roblox.com/library/476898... or on GitHub at https://github.com/rxi/classic

Have video suggestions or have some scripting-related questions? Contact me by:
Joining my Discord Server   / discord  
Adding me on Discord @okeanskiy#1889
Leaving a comment
DMing me on Twitter @okeanskiy_dev
(  / okeanskiy_dev  )
My Roblox Account Username - okeanskiy

Show support with a like and subscribe/notify yourself for more videos!

#Roblox #RobloxDev #RobloxTutorial

show more

Share/Embed