Menu
CoddyTech

The Pet Script

Lesson 1 of 18 in Coddy's Roblox Game: Pet Simulator course.

In this course you build a pet simulator: break coin piles, hatch eggs, collect pets that follow you and dig faster, open a new zone, and keep it all saved.

This game has two scripts. PetServer, a Script, runs on Roblox's server: it owns the coins, the pets and every rule. PetClient, a LocalScript inside the HUD, runs on each player's own device and draws their screen. You meet the client in chapter 2; for now its file only holds a note.

The numbers that balance the game live in a ModuleScript, ReplicatedStorage.Settings:

local Settings = require(game.ReplicatedStorage.Settings)
print(Settings.PileValue) --> 5
challenge icon

Challenge

Easy

Your PetServer Script is in ServerScriptService.

  1. Load the settings with require(game.ReplicatedStorage.Settings).
  2. Print A Meadow pile gives 5 coins, built from Settings.PileValue.
  3. When a player joins, give them a leaderstats Folder holding an IntValue named Coins.

Press Play, then Check.

Try it yourself

-- PetServer: the Script that runs the game, on the server.
local Players = game:GetService("Players")

-- 1. Load the settings: require the ModuleScript
--    game.ReplicatedStorage.Settings


-- 2. Print what a Meadow pile gives, using Settings.PileValue


-- 3. Give every player a Coins value on the leaderboard
--    (a Folder named leaderstats holding an IntValue named Coins)
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Roblox Game: Pet Simulator