I’ve been working on a game with boots that can increase your speed and jump power. I’ve tried making the saving system for if the player owns the boot. It just won’t work! I will provide what it my scripts.
Note : It’s kind of messy…
local DataStoreService = game:GetService('DataStoreService')
local DataBase = DataStoreService:GetDataStore("PlayerBase15")
local data = {}
function bootSetup(character, selectedBoots)
if character:FindFirstChild("LeftBoot") then
character:FindFirstChild("LeftBoot"):Destroy()
end
if character:FindFirstChild("RightBoot") then
character:FindFirstChild("RightBoot"):Destroy()
end
local leftBoot2 = game:GetService('ReplicatedStorage'):WaitForChild("Boots"):FindFirstChild(selectedBoots.Value):Clone()
leftBoot2:SetPrimaryPartCFrame(character["Left Leg"].CFrame * CFrame.new(0,-.6,0) * CFrame.Angles(0,math.rad(270),0))
leftBoot2.Parent = character
leftBoot2.WeldConstraint.Part0 = leftBoot2.PrimaryPart
leftBoot2.WeldConstraint.Part1 = character["Left Leg"]
leftBoot2.Name = "LeftBoot"
local rightBoot2 = game:GetService('ReplicatedStorage'):WaitForChild("Boots"):FindFirstChild(selectedBoots.Value):Clone()
rightBoot2:SetPrimaryPartCFrame(character["Right Leg"].CFrame * CFrame.new(0,-.6,0) * CFrame.Angles(0,math.rad(270),0))
rightBoot2.Parent = character
rightBoot2.WeldConstraint.Part0 = rightBoot2.PrimaryPart
rightBoot2.WeldConstraint.Part1 = character["Right Leg"]
rightBoot2.Name = "RightBoot"
end
game.Players.PlayerAdded:Connect(function(player)
local boots = Instance.new("Folder", player)
boots.Name = "Boots"
local success, playerData
success, playerData = pcall(function()
return DataBase:GetAsync(player.UserId)
end)
if success then
if not playerData then
playerData = {
["SelectedBoots"] = "Default",
}
for i, boot in pairs(game:GetService("ReplicatedStorage"):WaitForChild("Boots"):GetChildren()) do
if boot.Name == "Default" then
table.insert(playerData, {
[boot.Name] = {
["BootName"] = boot.Name,
["Owned"] = true
}
})
else
table.insert(playerData, {
[boot.Name] = {
["BootName"] = boot.Name,
["Owned"] = false
}
})
end
end
print(playerData)
end
data[player.UserId] = playerData
end
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
for i, boot in pairs(game:GetService("ReplicatedStorage"):WaitForChild("Boots"):GetChildren()) do
local cloneBoot = Instance.new("BoolValue", boots)
cloneBoot.Name = boot.Name
if data[player.UserId][boot.Name] then
if data[player.UserId][boot.Name].Owned == true then
cloneBoot.Value = true
else
cloneBoot.Value = false
end
else
if boot.Name == "Default" then
cloneBoot.Value = true
else
cloneBoot.Value = false
end
end
end
local height = Instance.new("NumberValue", leaderstats)
height.Name = "Height"
local selectedBoots = Instance.new("StringValue", player)
selectedBoots.Name = "SelectedBoots"
selectedBoots.Value = playerData.SelectedBoots
local character = player.Character or player.CharacterAdded:Wait()
bootSetup(character, selectedBoots)
selectedBoots.Changed:Connect(function()
data[player.UserId].SelectedBoots = selectedBoots.Value
bootSetup(character, selectedBoots)
end)
player.CharacterAdded:Connect(function(c)
character = c
bootSetup(character, selectedBoots)
end)
while wait() do
for i, item in pairs(boots:GetChildren()) do
item:GetPropertyChangedSignal("Value"):Connect(function()
data[player.UserId][item.Name].Owned = item.Value
end)
end
local humanoidPart = character:WaitForChild("HumanoidRootPart") or character:WaitForChild("Torso")
if humanoidPart then
height.Value = math.round(humanoidPart.Position.Y / 3)
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local totalTable = {}
table.insert(totalTable, {
["SelectedBoots"] = player:WaitForChild("SelectedBoots").Value
})
for i, boot in pairs(player:WaitForChild("Boots"):GetChildren()) do
table.insert(totalTable, {
[boot.Name] = {
["BootName"] = boot.Name,
["Owned"] = boot.Value
}
})
end
local success, playerData
success, playerData = pcall(function()
print(totalTable)
return DataBase:SetAsync(player.UserId, totalTable)
end)
end)