Idk if there's a better way to do this, but, if you can only have one of each item(i assume this is what you want since i can see it's guns) you would have a DataStore for each item, then the value gets saved as 1 or 0 depending on if you have the gun or not
local datastore = game:GetService("DataStoreService")
local RS = game:GetService("ReplicatedStorage")
local gun1 = datastore:GetDataStore("Gun1SaveSystem")
local gun2 = datastore:GetDataStore("Gun2SaveSystem")
local gun3 = datastore:GetDataStore("Gun3SaveSystem")
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "GunsFolder"
local gun1 = Instance.new("IntValue", folder)
gun1.Name = "Gun1"
local gun2 = Instance.new("IntValue", folder)
gun2.Name = "Gun2"
local gun3 = Instance.new("IntValue", folder)
gun3.Name = "Gun3"
gun1.Value = ds1:GetAsync(plr.UserId) or 0
gun1:SetAsync(plr.UserId, gun1.Value)
gun2.Value = ds1:GetAsync(plr.UserId) or 0
gun2:SetAsync(plr.UserId, gun2.Value)
gun3.Value = ds1:GetAsync(plr.UserId) or 0
gun3:SetAsync(plr.UserId, gun3.Value)
if gun1.Value == 1 then
local gun = RS.Guns.gun1:Clone()
gun.Parent = plr.StarterGear
end
if gun2.Value == 1 then
local gun = RS.Guns.gun2:Clone()
gun.Parent = plr.StarterGear
end
if gun3.Value == 1 then
local gun = RS.Guns.gun3:Clone()
gun.Parent = plr.StarterGear
end
gun1.Changed:connect(function()
gun1:SetAsync(plr.UserId, gun1.Value)
end)
gun2.Changed:connect(function()
gun2:SetAsync(plr.UserId, gun2.Value)
end)
gun3.Changed:connect(function()
gun3:SetAsync(plr.UserId, gun3.Value)
end)
end)
NOTE: I Havn't tested it, but i would do something like this
3 comments
Maybe if you researched this before asking, you would have found the millions of other people who asked the EXACT SAME QUESTION.
This is the excact script from a youtube video, did you even TRY to make it work on your own?
Yeah