so i made a data store script with 2 bool values (i mean i made more values but i just talking about those two rn) so basically one of them called REALKnife and one of the called Stick, and also i made two parts in the workspace one with Knife Image and one with Stick image, and inside of them there’s a clicke detectors
those two parts
so the datastore2 script places inside serverScriptService:
--variables
local DataStore2 = require(game:GetService("ServerScriptService").MainModule)
local mainkey = "eee"
DataStore2.Combine(mainkey, "Stats","SOULS","ITEMS","FOOD","ARMOR")
-- data table
local function SetDataTable()
local UserData = {
Stats = {
["EXP"] = 0,
["GOLD"] = 0,
["RESET"] = 0,
["LOVE"] = 1
},
SOULS = {
["BasicSoul"] = true,
["Determination"] = false,
["Integrity"] = false,
["Justice"] = false,
["Perseverance"] = false,
["Kindness"] = false,
["Bravery"] = false,
["Patience"] = false,
["HATE"] = false
},
ITEMS = {
["Stick"] = true,
["REALKnife"] = false
},
ARMOR = {
["Bandage"] = true,
["HeartLocket"] = false
},
FOOD = {
["MonsterCandy"] = 0,
},
}
return UserData
end
--main
game.Players.PlayerAdded:Connect(function(plr)
local UserData = DataStore2(mainkey,plr):Get(SetDataTable())
local gaster = Instance.new("Folder")
gaster.Name = "TobyFox"
local soulsfolder = Instance.new("Folder")
soulsfolder.Name = "SOULS"
local ITEMS = Instance.new("Folder")
ITEMS.Name = "ITEMS"
local ARMOR = Instance.new("Folder")
ARMOR.Name = "ARMOR"
local FOOD = Instance.new("Folder")
FOOD.Name = "FOOD"
--userStats
local LOVE = Instance.new("IntValue")
LOVE.Name = "LOVE"
local GOLD = Instance.new("IntValue")
GOLD.Name = "GOLD"
local RESET = Instance.new("IntValue")
RESET.Name = "RESET"
local EXP = Instance.new("IntValue")
EXP.Name = "EXP"
--souls
local BasicSoul = Instance.new("BoolValue")
BasicSoul.Name = "BasicSoul"
local Determination = Instance.new("BoolValue")
Determination.Name = "Determination"
local Justice = Instance.new("BoolValue")
Justice.Name = "Justice"
local Integrity = Instance.new("BoolValue")
Integrity.Name = "Integrity"
local Bravery = Instance.new("BoolValue")
Bravery.Name = "Bravery"
local Kindness = Instance.new("BoolValue")
Kindness.Name = "Kindness"
local Patience = Instance.new("BoolValue")
Patience.Name = "Patience"
local Perseverance = Instance.new("BoolValue")
Perseverance.Name = "Perseverance"
local HATE = Instance.new("BoolValue")
HATE.Name = "HATE"
--items
local Stick = Instance.new("BoolValue")
Stick.Name = "Stick"
local REALKnife = Instance.new("BoolValue")
REALKnife.Name = "REALKnife"
--Armor
local Bandage = Instance.new("BoolValue")
Bandage.Name = "Bandage"
local HeartLocket = Instance.new("BoolValue")
HeartLocket.Name = "HeartLocket"
--Food
local MonsterCandy = Instance.new("IntValue")
MonsterCandy.Name = "MonsterCandy"
--StoreInFolder
StatsData = DataStore2("Stats", plr)
SoulsData = DataStore2("SOULS", plr)
local ItemsData = DataStore2("ITEMS",plr)
local FoodData = DataStore2("FOOD", plr)
local ArmorData = DataStore2("ARMOR", plr)
--Stats data
local function UpdateStats(UpdateValue) -- updates value to current data
LOVE.Value = StatsData:Get(UpdateValue).LOVE
EXP.Value = StatsData:Get(UpdateValue).EXP
GOLD.Value = StatsData:Get(UpdateValue).GOLD
RESET.Value = StatsData:Get(UpdateValue).RESET
end
--Soul data
local function UpdateSouls(UpdateValue)
BasicSoul.Value = SoulsData:Get(UpdateValue).BasicSoul
Determination.Value = SoulsData:Get(UpdateValue).Determination
Perseverance.Value = SoulsData:Get(UpdateValue).Perseverance
Patience.Value = SoulsData:Get(UpdateValue).Patience
Kindness.Value = SoulsData:Get(UpdateValue).Kindness
Bravery.Value = SoulsData:Get(UpdateValue).Bravery
Justice.Value = SoulsData:Get(UpdateValue).Justice
Integrity.Value = SoulsData:Get(UpdateValue).Integrity
HATE.Value = SoulsData:Get(UpdateValue).HATE
end
--items Data
local function UpdateITEM(UpdateValue)
Stick.Value = SoulsData:Get(UpdateValue).Stick
REALKnife.Value = SoulsData:Get(UpdateValue).REALKnife
end
--update data
UpdateStats(UserData.Stats)
UpdateSouls(UserData.SOULS)
UpdateITEM(UserData.ITEMS)
StatsData:OnUpdate(UpdateStats)
SoulsData:OnUpdate(UpdateSouls)
ItemsData:OnUpdate(UpdateITEM)
--parent
gaster.Parent = plr
soulsfolder.Parent = plr
ITEMS.Parent = plr
--allinonestats
--stats
LOVE.Parent = gaster
RESET.Parent = gaster
EXP.Parent = gaster
GOLD.Parent = gaster
--Souls
Determination.Parent = soulsfolder
BasicSoul.Parent = soulsfolder
Perseverance.Parent = soulsfolder
Integrity.Parent = soulsfolder
Justice.Parent = soulsfolder
Kindness.Parent = soulsfolder
Bravery.Parent = soulsfolder
Patience.Parent = soulsfolder
HATE.Parent = soulsfolder
--ITENS
REALKnife.Parent = ITEMS
Stick.Parent = ITEMS
--LEVE SYSTEN start
EXP.Changed:connect(function()
if UserData.Stats.LOVE < 100 then
if UserData.Stats.EXP >= UserData.Stats.LOVE*25 + 10 then
UserData.Stats.EXP = UserData.Stats.EXP - (UserData.Stats.LOVE*25 + 10)
UserData.Stats.LOVE = UserData.Stats.LOVE + 1
StatsData:Set(UserData.Stats)
end
end
end)
end)
basically i made a script that changes the stick bool value to false and Realknife value to true if you click the part with the knife picture, and the stick to true and Realknife to false if you click the part with the stick picture
the script:
workspace.Chooseitem.Knife.ClickDetector.MouseClick:Connect(function(plr)
local itemdata = DataStore2("ITEMS", plr)
local UserData = DataStore2(mainkey,plr):Get(SetDataTable())
local Stick = UserData.ITEMS.Stick
local REALKnife = UserData.ITEMS.REALKnife
if REALKnife == true then
UserData.ITEMS["REALKnife"] = false
UserData.ITEMS["Stick"] = true
itemdata:Set(UserData.ITEMS)
Stick = true
REALKnife = false
elseif REALKnife == false then
UserData.ITEMS["REALKnife"] = true
UserData.ITEMS["Stick"] = false
itemdata:Set(UserData.ITEMS)
REALKnife = true
Stick = false
end
plr:LoadCharacter()
end)
workspace.Chooseitem.Stick.ClickDetector.MouseClick:Connect(function(plr)
local itemdata = DataStore2("ITEMS", plr)
local UserData = DataStore2(mainkey,plr):Get(SetDataTable())
local Stick = UserData.ITEMS.Stick
local REALKnife = UserData.ITEMS.REALKnife
if Stick == true then
UserData.ITEMS["Stick"] = true
itemdata:Set(UserData.ITEMS)
Stick = true
elseif Stick == false then
UserData.ITEMS["REALKnife"] = false
UserData.ITEMS["Stick"] = true
itemdata:Set(UserData.ITEMS)
REALKnife = false
Stick = true
end
plr:LoadCharacter()
end)
also, i made two tools placed inside StarterPack, one is knife and one stick, so all i want to do is to make a if statement, that says:
if REALKnife.Value == true then
the weapon will be in the backpack
elseif false
the weapon won’t be inside backpack
end
same with the stick…
hope this post was understandable , thanks in advance 