Help - ‘Basic’ looting system

Hey! I’ve been working on a survival game for the past year, though I’m completely new to scripting and have a question related to creating a loot system.

What do I want to achieve?

  • Basic / Simplistic, yet useful looting system think of something like Apocalypse Rising 1 or Deadmist 2 loot systems.

Node Example

a loot system that uses ‘nods’ that can spawn specific loot items (ex. a purple node spawns an item from a medical category / list and a red node spawns weapons, check “image 1” for reference). I want to make it so that these nods can be placed wherever I want a specific item category to spawn. Once clicked on a spawned item, the item should disappear from the ground and should be moved into a players inventory. After a certain amount of time (ex. 50 minutes), all items should respawn a random item from the specific category

What’s the issue?

Due to me not knowing how to script yet, I don’t really know how to create a loot system. I’ve tried finding tutorials / help on YouTube and the DevForum, but simply could not find anything that I wanted or that was helpful to a degree where I am able to create my own looting system, hence why I went to ask for help on the DevForum myself.

So my question: Does anybody have any sites (that may be useful), tutorials or perhaps advice from their own experience(s) on how I can create the loot system I have in mind?

Note: I do not need / want systems made by others (ex. free models), I just need some form of tutorial / help so I can have a basic understanding of how loot systems / scripting them works.

(Additional) Contact Information:

  • Dizzy: Fred.#7638

Thanks in advance,

Cheers,

Fred

1 Like

can you give us the script :confused: so I can help you easier

This is something that would most likely be called a “Tool spawner”, “Respawning tool” or similar.
If you search for something like “roblox tool spawning system”, I’m sure you will find plenty posts and basic tutorials :slight_smile:.

Okay, I’ll take a look! Thank you :slight_smile:

1 Like

First thing I would do is create a folder in replicated storage and call it “Loot”

Then create folders in “Loot” for each type of tool.

Put the tools in the folders that you want.

Here is an example:
image

Then make a new script inside the node with the following code:

local ReplicatedStorage = game:GetService("ReplicatedStorage") --ReplicatedStorage
local Loot = ReplicatedStorage.Loot --The folder containing all the loot

script.Parent.Transparency = 1 --Make the node invisible
script.Parent.CanCollide = false --Turn off collitions with the node

function SpawnLoot() --This is a fuction, anything that happens between here and line 19 where it says end will happen any time SpawnLoot() is in the code. E.g. line 21
	local LootGroup = Loot:FindFirstChild(script.Parent:GetAttribute("LootType")) --Get the right type of loot based off of the attrabute
	
	local LootTable = {} --Create a empty table
	
	for i, Tool in pairs(LootGroup:GetChildren()) do --Fill the table with all the loot in the loot group
		table.insert(LootTable, Tool)
	end
	
	local ChosenLoot = LootTable[math.random(1, #LootTable)] --Pick a random tool from the loot group
	
	local Loot = ChosenLoot:Clone() --Make a copy of it
	
	Loot.Parent = workspace --Put it in workspace
	Loot.Handle.CFrame = script.Parent.CFrame --Move to to the position of the node
end

SpawnLoot()

Now you need to tell the script what type of loot the node will spawn.

Step one: Make a new attribute for the node. Select the node and then in the properties panel, make a new attribute by clicking on add attribute button.

Step two: Make the name of the attribute loot type and make sure that attribute type is set to string.

Step three: Hit save and then you will see the new attribute.
image

Step four: Change the attribute to match the name of the folder you want the node to spawn loot from.

I don’t think that I explained stuff super well so please ask me if you have questions.

3 Likes

Holy moly! Thank you so much! I’ll let you know if I stumbled across any issues and such! :smiley:

Also, I would recommend checking out this: Coding Fundamentals | Roblox Creator Documentation

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.