01 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "CheckTools" ) |
02 | game.Players.PlayerAdded:connect( function (player) |
03 |
04 | local ToolSaveFolder = Instance.new( "Folder" , player) |
05 | ToolSaveFolder.Name = "ToolSaveFolder" |
06 |
07 | local tool 1 = Instance.new( "IntValue" , ToolSaveFolder) |
08 | tool 1. Name = "Dirt" |
09 |
10 | local tool 2 = Instance.new( "IntValue" , ToolSaveFolder) |
11 | tool 2. Name = "Rock" |
12 | wait( 5 ) |
13 | if player.ToolSaveFolder.Dirt.Value > = 1 then |
14 | game.ServerStorage.Tools.Dirt:Clone().Parent = player.Backpack |
15 | game.ServerStorage.Tools.Dirt:Clone().Parent = player.StarterGear |
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.
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.
1 | if IfThisWeapon = = true then |
2 | weapon = game.ReplicatedStorage.Weapon:Clone() |
3 | weapon.Parent = player |
4 | else |
5 | print ( "Player does not have this weapon/tool" ) |
6 | end |
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