-
What do you want to achieve? I wanted to save the value of the boolvalue in the player folder but I’ve found a big problem that my brain couldn’t solve.
-
What is the issue? I am very new to datastoring coding, and right now I’m trying to saving alots of item boolvalue. after I’ve coded the script, it’s going well BUT when i turned one of the boolvalue to True and leave and rejoin. It’s somehow make all the other value goes True too. and when I tried to change it back by changing the datastore, all the value to false again. and leave and rejoin the game again. It’s still all the value are True. Please help I’ve been suffering this problem for 5 hours+ now (Sorry for my bad english)
-
What solutions have you tried so far? Tried the dumbest ways possible that my brain could think of to fix this problem but it doesn’t work
---------This is Server Script In ServerScriptService-------------
local SWD = DSS:GetDataStore("DATA1")
local GVC = DSS:GetDataStore("DATA2")
local LSR = DSS:GetDataStore("DATA3")
local SPC = DSS:GetDataStore("DATA4")
game.Players.PlayerAdded:Connect(function(plr)
print("Loaded")
SWD:GetAsync(plr.UserId)
GVC:GetAsync(plr.UserId)
LSR:GetAsync(plr.UserId)
SPC:GetAsync(plr.UserId)
plr:WaitForChild("OwnedItems"):FindFirstChild("Sword").Value = SWD or false
plr:WaitForChild("OwnedItems"):FindFirstChild("Gravity Coil").Value = GVC or false
plr:WaitForChild("OwnedItems"):FindFirstChild("Laser Gun").Value = LSR or false
plr:WaitForChild("OwnedItems"):FindFirstChild("Speed Coil").Value = SPC or false
print(SWD)
print(GVC)
print(LSR)
print(SPC)
end)
game.Players.PlayerRemoving:Connect(function(plr)
print("saved")
local OIT = plr:WaitForChild("OwnedItems")
local SWD_VALUE = OIT:FindFirstChild("Sword").Value
local GVC_VALUE = OIT:FindFirstChild("Gravity Coil").Value
local LSR_VALUE = OIT:FindFirstChild("Laser Gun").Value
local SPC_VALUE = OIT:FindFirstChild("Speed Coil").Value
print(SWD_VALUE)
print(GVC_VALUE)
print(LSR_VALUE)
print(SPC_VALUE)
SWD:SetAsync(plr.UserId, SWD_VALUE)
GVC:SetAsync(plr.UserId, GVC_VALUE)
LSR:SetAsync(plr.UserId, LSR_VALUE)
SPC:SetAsync(plr.UserId, SPC_VALUE)
end)
Yes I know the code looks dumb, but I’m new to this topic. Please help!