Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to save weapon's stats ?

Asked by 4 years ago

I want to create an item, players will randomly receive it by killing npc, the stats of the item will be random. It's similar to the weapon in the game "Dungeon Quest". How do I save weapons data and weapon's stats? I can save weapon but i dont know how to save weapon's stats.

0
I have awnsered your question. RBLXNogin 187 — 4y

1 answer

Log in to vote
0
Answered by
RBLXNogin 187
4 years ago
Edited 4 years ago

Hello there, RBLXNogin here and the solution to your problem is something known as "Leaderstats". In any program, application, and even game saving player and user data is an essential. Using leaderstats, the game developer can create and maintain functions that allow the game to save player data.

according to ROBLOX, a leaderboard as an object that is named as 'leaderstats' and is located inside the player. The data inside the leaderboard is defined as a value object inside the leaderstats object (Player>leaderstats>ValueObject). Now that you understand basics of leaderboards, let me show you a script that creates cash for the player.

You want to save playerdata, so here is the solution. The first thing you need to do is insert a script inside the workspace (script not localscript). After that, insert the code that creates the leaderboard. As an example, I am going to create a script that creates a leaderboard for the amount of money you have, however you can customise it to your own needs.

function OnEnter(plr)
    local leaderstats = Instance.new("Folder")
    leaderstats.Parent = plr
    leaderstats.Name = "leaderstats"


    local weapon = Instance.new("StringValue")
    weapon.Name = "CurrentWeapon"
    weapon.Value = "GunV2" -- name of weapon. You can change or add a script to automatically do so.
end

game:GetService("Players").ChildAdded:Connect(OnEnter)

After you create your leaderstats (to set and change weapon values within a player). You can use something known as DataStoreService (DSS) to save the values.

Here are some links to help you get started:

Alvin Blox Tutorial and ROBLOX WIKIA

I have to go, however everything I have said should help you with your goal. If i was useful, please select the green checkmark. Anyways, enjoy

Ad

Answer this question