So im trying to put in this tool saver but it wants to have the tools in a folder
But that conflicts with my Buying script.
local ds = game:GetService("DataStoreService")
local coinDs = ds:GetDataStore("Coins")
local cashDs = ds:GetDataStore("Cash")
local lighting = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(plr)
local id = game.Players:GetUserIdFromNameAsync(plr.Name)
local player = game.Players:FindFirstChild(plr.Name)
local coinsKey = "Coins_"..id
local coins = coinDs:GetAsync(coinsKey)
if coins ~= nil then
else
game.ServerStorage.Coin:Clone().Parent = player.Backpack
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
end)```
And here is the other scripts
This script gives the tool
```local player = game.Players.LocalPlayer
script.Parent.Close.MouseButton1Click:Connect(function()
local camera = game.Workspace.CurrentCamera
camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
camera.CameraType = "Custom"
script.Parent.Parent.Enabled = false
end)
script.Parent["Quick Button"].MouseButton1Click:connect(function()
if game.Players:FindFirstChild(player.Name).leaderstats.Cash.Value >=100
and game.Players:FindFirstChild(player.Name).Backpack:FindFirstChild("Coin Quick")==nil
and game.Workspace:FindFirstChild(player.Name):FindFirstChild("Coin Quick")==nil then
game.ReplicatedStorage.Purchase.Purchase1:FireServer()
game.ServerStorage.Tools:FindFirstChild("Coin Quick"):Clone().Parent = game.Players:FindFirstChild(player.Name).Backpack
end
end)```
And heres the open source tool script i got
```--[[
5/2/2020
βββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ Version 1.0
by guywithapoo
Thank you for using Tool Saver! I hope this small kit will help beginning developers create big things in the future.
If you find any issues, please message guywithapoo on Roblox.
A few notes:
- This kit does not save the tools when a player leaves, only when they die. If this is a feature you would like to be added,
please message guywithapoo!
- If someone has more than 1 copy of a tool, it will only save one.
- The function "loadTools" will find all of the tools in a few specific areas where stuff could be stored. Areas Include:
Workspace, ReplicatedStorage, and ServerStorage. If you would like to add more areas to search for tools, take the example in
the function and edit it accordingly.
- I will be providing commas in certain areas to help explain what I am doing.
Also, if you would like to exclude certain tools from being saved, go to line 108 to see where you can exclude them.
--]]
print("Thanks for using ToolSaver by guywithapoo!")
if script.Parent ~= game.ServerScriptService then -- if it isnt already in ServerScriptService it will put itself there.
script.Parent = game.ServerScriptService
end
if not game.ServerStorage:FindFirstChild("Tools") then -- if there isnt a tools folder in ServerStorage its gonna make one.
Tools = Instance.new("Folder")
Tools.Parent = game.ServerStorage
Tools.Name = "Tools"
end
function loadTools()
--[[ --<< REMOVE THESE IF YOU ADD MORE!
for i,v in pairs (EXAMPLE:GetDescendants()) do
if v.ClassName == "Tool" then
local clone = v:Clone()
clone.Parent = game.ServerStorage.Tools
end
end
--]] --<< REMOVE THESE IF YOU ADD MORE!
for i,v in pairs (workspace:GetDescendants()) do -- searches for Tools in the workspace
if v.ClassName == "Tool" then
local clone = v:Clone()
clone.Parent = game.ServerStorage.Tools
end
end
for i,v in pairs (game.ReplicatedStorage:GetDescendants()) do -- searches for Tools in ReplicatedStorage
if v.ClassName == "Tool" then
local clone = v:Clone()
clone.Parent = game.ServerStorage.Tools
end
end
for i,v in pairs (game.ServerStorage:GetDescendants()) do -- searches for Tools in ServerStorage
if v.ClassName == "Tool" and v.Parent ~= game.ServerStorage.Tools then
local clone = v:Clone()
clone.Parent = game.ServerStorage.Tools
end
end
for i,v in pairs (game.Lighting:GetDescendants()) do -- searches for Tools in Lighting
if v.ClassName == "Tool" then
local clone = v:Clone()
clone.Parent = game.ServerStorage.Tools
end
end
end
loadTools() -- fires the loadtools function
game.Players.PlayerAdded:Connect(function(player) -- this can be left alone, unless you are trying to experiment and learn :)
local tools_table = { -- a dictionary, lookup on the wiki
}
player.CharacterAdded:Connect(function(character)
for i,v in pairs (tools_table) do
-- when a player is added, it is checking the dictionary and loading in the items after death.
-- print(i,v)
if game.ServerStorage.Tools:FindFirstChild(i) then
local clone = game.ServerStorage.Tools[i]:Clone()
clone.Parent = player.Backpack
end
end
character:FindFirstChild("Humanoid").Died:Connect(function()
-- print(player,"died.")
-- when a player dies, it is going to add the names of the items they have in Backpack to the dictionary.
for _,tool in pairs (player.Backpack:GetChildren()) do
if not tools_table[tool.Name] then
tools_table[tool.Name] = true
end
end
for i,v in pairs (tools_table) do -- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EXCLUDE CERTAIN ITEMS!
-- this excludes certain items.
if i == "EXAMPLE" or i == "EXAMPLE2" or i == "EXAMPLE3" then -- change EXAMPLE, and add more if you need to exclude more
--print("removed:",i)
tools_table[i] = nil
end
end
for i,v in pairs (tools_table) do
-- this removes an item from the dictionary if they dropped it to prevent duplication.
if not player.Backpack:FindFirstChild(i) then
--print("removed:",i)
tools_table[i] = nil
end
end
for _,tool in pairs (character:GetChildren()) do
-- checks inside of the character and saves that too, just in case if they are holding an item when they die.
if tool.ClassName == "Tool" then
if not tools_table[tool.Name] then
tools_table[tool.Name] = true
end
end
end
end)
end)
end)