Hey! I want to put make this Script work -- Starter -- load library -- local…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Hey! I want to put make this Script work -- Starter
-- | load library | -- local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerScriptService = game:GetService("ServerScriptService") local Library = ReplicatedStorage:WaitForChild("Library") local Client = ReplicatedStorage:WaitForChild("Library"):WaitForChild("Client") local ServerLibrary = ServerScriptService:WaitForChild("Library")
-- | shared modules | -- local Directory = require(Library.Directory) local Signal = require(Library.Signal) local Functions = require(Library.Functions) local Items = require(Library.Items)
-- | server modules | -- local Network = require(ServerLibrary.Network) local Saving = require(ServerLibrary.Saving) local Ranks = require(ServerLibrary.Ranks) local Inventory = require(ServerLibrary.Inventory) local Currency = require(ServerLibrary.Currency) local Gamepasses = require(ServerLibrary.Gamepasses)
--- Reference
function validate(pet) if not (pet == "Cat" or pet == "Dog" or pet == "Corgi" or pet == "Axolotl") then return false end
return true
end
Network.Invoked("Pick Starter Pets").OnInvoke = function(player, petA, petB) local save = Saving.Get(player) if not save then return nil end
if save.PickedStarterPet then
return false, "You already picked a starter!"
end
if not validate(petA) or not validate(petB) then
return false, "Failed to validate pet!"
end
save.PickedStarterPet = true
save.StarterPetA = petA
save.StarterPetB = petB
for _, gamepass in pairs(Directory.Gamepasses) do
Gamepasses.Give(player, gamepass._id)
end
return pcall(function()
Inventory.AddItem(player, Items.Pet(petA)) Inventory.AddItem(player, Items.Pet(petB))
end)
end
For a PSX game. The first script is a Ps99 Script --------| Setting |--------
--------| Library |-------- local _L = require(game.ReplicatedStorage:WaitForChild("Framework"):WaitForChild("Library")) while (not _L.Loaded) do game:GetService("RunService").Heartbeat:Wait() end
--------| Reference |--------
--------| Variables |--------
_L.Network.Invoked("Pick Starter").OnInvoke = function(player,pet) local save = _L.Saving.Get(player)
if (not save) then
return false, "???"
end
if save.PickedStarter == true then
return false, "already picked"
end
local starters = {
["cat"] = "1",
["dog"] = "2",
["bunny"] = "3"
}
local selectedPet = nil
if starters[pet] then
save.PickedStarter = true
selectedPet = _L.Pets.Create(player, starters[pet], {s = 1})
return true, selectedPet
end
return false, "???"
end
and this is a Ps99 Script. I want u to replace the Ps99 Script with the PSX script but make it work
Hey! Below is a drop-in replacement for your old PS99 starter script, rewritten to use your PSX framework (the “Pick Starter Pets” logic from your first snippet). Just delete your old PS99 handler and paste this in its place under ServerScriptService/Library/....
-- Server > StarterPets.lua
-- Handles the “Pick Starter Pets” remote invoke for PSX
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
-- wait for your folder structure
local Library = ReplicatedStorage:WaitForChild("Library")
local ServerLib = ServerScriptService:WaitForChild("Library")
-- shared modules
local Directory = require(Library.Directory)
local Signal = require(Library.Signal)
local Functions = require(Library.Functions)
local Items = require(Library.Items)
-- server modules
local Network = require(ServerLib.Network)
local Saving = require(ServerLib.Saving)
local Inventory = require(ServerLib.Inventory)
local Gamepasses = require(ServerLib.Gamepasses)
-- list of valid starter pets
local VALID_PETS = {
Cat = true,
Dog = true,
Corgi = true,
Axolotl = true,
}
local function isValidPet(petName)
return VALID_PETS[petName] or false
end
Network.Invoked("Pick Starter Pets").OnInvoke = function(player, petA, petB)
-- 1) load the player's save
local save = Saving.Get(player)
if not save then
return false, "Could not load save!"
end
-- 2) ensure they haven't already picked
if save.PickedStarterPet then
return false, "You already picked your starter!"
end
-- 3) validate both selections
if not (isValidPet(petA) and isValidPet(petB)) then
return false, "Invalid starter choice!"
end
-- 4) mark as picked & store name keys
save.PickedStarterPet = true
save.StarterPetA = petA
save.StarterPetB = petB
-- 5) grant any free gamepasses
for _, gpInfo in ipairs(Directory.Gamepasses) do
Gamepasses.Give(player, gpInfo._id)
end
-- 6) give the two pets
local ok, err = pcall(function()
Inventory.AddItem(player, Items.Pet(petA))
Inventory.AddItem(player, Items.Pet(petB))
end)
-- return success or the error message
return ok, err
end
What changed?
• We load your PSX modules (Directory, Items, Network, etc.)
• We renamed the invoke to "Pick Starter Pets" (matching your first snippet)
• We validate two pets instead of one
• We tag the save, give gamepasses, then add both pet-items via Inventory.AddItem
Drop this script in, delete the old PS99 version, and your starter-pet flow should light up! Let me know if you hit any errors or need tweaks. 🚀
--------| Setting |--------
--------| Library |-------- local _L = require(game.ReplicatedStorage:WaitForChild("Framework"):WaitForChild("Library")) while (not _L.Loaded) do game:GetService("RunService").Heartbeat:Wait() end
--------| Reference |--------
--------| Variables |--------
_L.Network.Invoked("Pick Starter").OnInvoke = function(player,pet) local save = _L.Saving.Get(player)
if (not save) then
return false, "???"
end
if save.PickedStarter == true then
return false, "already picked"
end
local starters = {
["cat"] = "1",
["dog"] = "2",
["bunny"] = "3"
}
local selectedPet = nil
if starters[pet] then
save.PickedStarter = true
selectedPet = _L.Pets.Create(player, starters[pet], {s = 1})
return true, selectedPet
end
return false, "???"
end
I want this script to select 2 pets and if only 1 pet is picked, it needs to choose 1 more!
Here’s a drop-in replacement for your old PS99 “Pick Starter” handler that:
• Lets you pass up to two pet-names (strings)
• If you only pass one valid pet, it randomly picks a second (distinct) one for you
• If you pass two, it’ll use both (as long as they’re valid and different)
Just replace your existing _L.Network.Invoked("Pick Starter")… block with this:
-- ServerScriptService/…/StarterSelector.lua
local RunService = game:GetService("RunService")
local _L = require(game.ReplicatedStorage:WaitForChild("Framework"):WaitForChild("Library"))
-- wait until the library signals it's ready
while not _L.Loaded do
RunService.Heartbeat:Wait()
end
_L.Network.Invoked("Pick Starter").OnInvoke = function(player, petA, petB)
-- 1) load player save
local save = _L.Saving.Get(player)
if not save then
return false, "Could not load save"
end
-- 2) ensure they haven't already picked
if save.PickedStarter then
return false, "You already picked your starter!"
end
-- 3) your starter pool (key = lowercase pet name, value = pet ID)
local starters = {
cat = "1",
dog = "2",
bunny = "3",
}
-- helper to normalize & test validity
local function isValid(name)
return name and starters[name:lower()]
end
-- 4) collect chosen names (unique and valid)
local picks = {}
local seen = {}
for _, rawName in ipairs({ petA, petB }) do
if isValid(rawName) then
local key = rawName:lower()
if not seen[key] then
table.insert(picks, key)
seen[key] = true
end
end
end
-- 5) if only one valid was passed, pick a random second one
if #picks == 1 then
local pool = {}
for name, _ in pairs(starters) do
if not seen[name] then
table.insert(pool, name)
end
end
if #pool > 0 then
local rnd = pool[math.random(1, #pool)]
table.insert(picks, rnd)
end
end
-- 6) must end up with exactly two picks
if #picks < 2 then
return false, "Invalid starter choice(s)"
end
-- 7) mark them as having picked & create the pets
save.PickedStarter = true
local createdPets = {}
for _, name in ipairs(picks) do
local petId = starters[name]
-- pass your stats table as needed ({ s = 1 } for example)
local petObj = _L.Pets.Create(player, petId, { s = 1 })
table.insert(createdPets, petObj)
end
-- 8) return success + array of the two pet-objects
return true, createdPets
end
How it works step by step:
starters)save.PickedStarter = true and call _L.Pets.Create for eachtrue, {pet1Obj, pet2Obj}Now your client can do something like:
local ok, petsOrErr = Remote:InvokeServer("Pick Starter", "Cat", "Dog")
-- or
local ok, petsOrErr = Remote:InvokeServer("Pick Starter", "Bunny")
-- in the second case the script will auto-choose one more for you
Let me know if you hit any errors or need further tweaks! 🎉