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

How do you save a tool in your inventory to a value?

Asked by
thortol 22
9 years ago
01local DataStore = game:GetService("DataStoreService"):GetDataStore("CheckTools")
02  game.Players.PlayerAdded:connect(function(player)
03 
04local ToolSaveFolder = Instance.new("Folder", player)  
05ToolSaveFolder.Name = "ToolSaveFolder"
06 
07local tool1 = Instance.new("IntValue", ToolSaveFolder)
08tool1.Name = "Dirt"
09 
10local tool2 = Instance.new("IntValue", ToolSaveFolder)
11tool2.Name = "Rock"
12wait(5)
13if player.ToolSaveFolder.Dirt.Value >= 1 then
14    game.ServerStorage.Tools.Dirt:Clone().Parent = player.Backpack
15    game.ServerStorage.Tools.Dirt:Clone().Parent = player.StarterGear
View all 41 lines...

This script is suppose to save tools in your inventory. For example there is a tool called dirt in your inventory. So the code will save the value 1 into the value, and when the player logs in again, it will load a Dirt as the value is 1. However, the code doesn't seem to save the value 1.

1 answer

Log in to vote
0
Answered by
Scootakip 299 Moderation Voter
9 years ago

I'd suggest that when a player joins, have DataStore give them a value of IfThisWeapon. It should be a BoolValue, if the BoolValue is set tot true, it means they have the weapon, if it's set to false, they don't have the weapon.

1if IfThisWeapon == true then
2    weapon = game.ReplicatedStorage.Weapon:Clone()
3    weapon.Parent = player
4    else
5    print("Player does not have this weapon/tool")
6end

Obviously that script is unfinished and such, but you probably get the idea. If you need any help comment and I'll try to help you.

Summery: Use a Bool Value to show if a player has a certain weapon or not, as DataStore can't store tools

0
How do you let it check whether the player has the tool? thortol 22 — 9y
Ad

Answer this question