You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
A safe system that stores the players items (done, but it has a major flaw) -
What is the issue? Include screenshots / videos if possible!
When safing and taking out an item, it has a very high chance of giving/taking the items from the wrong person -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
different methods, none work
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
–LOCAL SCRIPT INSIDE THE GUI
local player = game.Players.LocalPlayer
script.Parent.Parent.Parent:GetPropertyChangedSignal("Visible"):Connect(function()
script.Parent.Text = player.Safe.GIS.Value
end)
player.Safe.GIS:GetPropertyChangedSignal("Value"):Connect(function()
player.PlayerGui.Safe.MainFrame.MainFrame.Item.Text = player.Safe.GIS.Value
end)
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Taking:FireServer()
script.Parent.Text = player.Safe.GIS2.Value
end)
SERVER SCRIPT IN SSS
local DataStore = game:GetService("DataStoreService")
--[[Uneeded; due to faster method
local Alr1 = false
local Alr2 = false
local Alr3 = false
local Alr4 = false
local Alr5 = false
--]]
local GISS = DataStore:GetDataStore("GISS")
local GISS2 = DataStore:GetDataStore("GISS2")
local GISS3 = DataStore:GetDataStore("GISS3")
local GISS4 = DataStore:GetDataStore("GISS4")
local GISS5 = DataStore:GetDataStore("GISS5")
local Guns = game.ReplicatedStorage.Guns:GetChildren()
--[[Uneeded; due to faster method
local Pistol = game.ReplicatedStorage.Guns:FindFirstChild("Pistol")
local AR = game.ReplicatedStorage.Guns:FindFirstChild("Assualt Rifle")
local SMG = game.ReplicatedStorage.Guns:FindFirstChild("SMG")
local BR = game.ReplicatedStorage.Guns:FindFirstChild("Burst Rifle")
local Shotty = game.ReplicatedStorage.Guns:FindFirstChild("Shotgun")
--]]
game.Players.PlayerAdded:Connect(function(p)
local SF = Instance.new("Folder")
SF.Parent = p
SF.Name = "Safe"
local GIS = Instance.new("StringValue")
GIS.Parent = SF
GIS.Name = "GIS"
GIS.Value = "Nothing"
local GIS2 = Instance.new("StringValue")
GIS2.Parent = SF
GIS2.Name = "GIS2"
GIS2.Value = "Nothing"
local GIS3 = Instance.new("StringValue")
GIS3.Parent = SF
GIS3.Name = "GIS3"
GIS3.Value = "Nothing"
local GIS4 = Instance.new("StringValue")
GIS4.Parent = SF
GIS4.Name = "GIS4"
GIS4.Value = "Nothing"
local GIS5 = Instance.new("StringValue")
GIS5.Parent = SF
GIS5.Name = "GIS5"
GIS5.Value = "Nothing"
local UserID = p.UserId
local data
local data2
local data3
local data4
local data5
local success, errormessage = pcall(function() --getting loaded data
data = GISS:GetAsync(UserID)
data2 = GISS2:GetAsync(UserID)
data3 = GISS3:GetAsync(UserID)
data4 = GISS4:GetAsync(UserID)
data5 = GISS5:GetAsync(UserID)
end)
if success and data ~= nil then
GIS.Value = data
end
if success and data2 ~= nil then
GIS2.Value = data2
end
if success and data3 ~= nil then
GIS3.Value = data3
end
if success and data4 ~= nil then
GIS4.Value = data4
end
if success and data5 ~= nil then
GIS5.Value = data5
end
game.ReplicatedStorage.Safing.OnServerEvent:Connect(function(p2, player)
if GIS.Value == "Nothing" then
local CV = player.Character:FindFirstChildOfClass("Tool").Name
for i, v in pairs(Guns) do
if v.Name == CV then
GIS.Value = CV
local Tool = player.Character:FindFirstChildOfClass("Tool")
Tool.Parent = player.Backpack
Tool:Destroy()
end
end
end
end)
game.ReplicatedStorage.Safing.OnServerEvent:Connect(function(p2, player)
if GIS2.Value == "Nothing" and GIS.Value ~= "Nothing" then
local CV = player.Character:FindFirstChildOfClass("Tool").Name
for i, v in pairs(Guns) do
if v.Name == CV then
GIS2.Value = player.Character:FindFirstChildOfClass("Tool").Name
local Tool = player.Character:FindFirstChildOfClass("Tool")
Tool.Parent = player.Backpack
Tool:Destroy()
end
end
end
end)
game.ReplicatedStorage.Safing.OnServerEvent:Connect(function(p2, player)
if GIS3.Value == "Nothing" and GIS2.Value ~= "Nothing" and GIS.Value ~= "Nothing" then
local CV = player.Character:FindFirstChildOfClass("Tool").Name
for i, v in pairs(Guns) do
if v.Name == CV then
GIS3.Value = player.Character:FindFirstChildOfClass("Tool").Name
local Tool = player.Character:FindFirstChildOfClass("Tool")
Tool.Parent = player.Backpack
Tool:Destroy()
end
end
end
end)
game.ReplicatedStorage.Safing.OnServerEvent:Connect(function(p2, player)
if GIS4.Value == "Nothing" and GIS3.Value ~= "Nothing" and GIS2.Value ~= "Nothing" and GIS.Value ~= "Nothing" then
local CV = player.Character:FindFirstChildOfClass("Tool").Name
for i, v in pairs(Guns) do
if v.Name == CV then
GIS4.Value = player.Character:FindFirstChildOfClass("Tool").Name
local Tool = player.Character:FindFirstChildOfClass("Tool")
Tool.Parent = player.Backpack
Tool:Destroy()
end
end
end
end)
game.ReplicatedStorage.Safing.OnServerEvent:Connect(function(p2, player)
if GIS5.Value == "Nothing" and GIS4.Value ~= "Nothing" and GIS3.Value ~= "Nothing" and GIS2.Value ~= "Nothing" and GIS.Value ~= "Nothing" then
local CV = player.Character:FindFirstChildOfClass("Tool").Name
for i, v in pairs(Guns) do
if v.Name == CV then
GIS5.Value = player.Character:FindFirstChildOfClass("Tool").Name
local Tool = player.Character:FindFirstChildOfClass("Tool")
Tool.Parent = player.Backpack
Tool:Destroy()
end
end
end
end)
game.ReplicatedStorage.Taking.OnServerEvent:Connect(function(player)
local Gs = game.ReplicatedStorage:GetChildren()
print(GIS.Value)
for i, v in pairs(game.ReplicatedStorage.Guns:GetChildren()) do
if v.Name == player.Safe.GIS.Value then
v:Clone().Parent = player.Backpack
player.Safe.GIS.Value = "Nothing"
end
end
--[[ Uneeded; due to faster method
if GIS.Value == "Pistol" then
Pistol:Clone().Parent = p.Backpack
GIS.Value = "Nothing"
end
if GIS.Value == "Assualt Rifle" then
AR:Clone().Parent = p.Backpack
GIS.Value = "Nothing"
end
if GIS.Value == "SMG" then
SMG:Clone().Parent = p.Backpack
GIS.Value = "Nothing"
end
if GIS.Value == "Burst Rifle" then
BR:Clone().Parent = p.Backpack
GIS.Value = "Nothing"
end
if GIS.Value == "Shotgun" then
Shotty:Clone().Parent = p.Backpack
GIS.Value = "Nothing"
end
-]]
end)
game.ReplicatedStorage.Taking2.OnServerEvent:Connect(function(player)
local Gs = game.ReplicatedStorage:GetChildren()
print(GIS2.Value)
for i, v in pairs(game.ReplicatedStorage.Guns:GetChildren()) do
if v.Name == player.Safe.GIS2.Value then
v:Clone().Parent = player.Backpack
player.Safe.GIS2.Value = "Nothing"
end
end
end)
game.ReplicatedStorage.Taking3.OnServerEvent:Connect(function(player)
local Gs = game.ReplicatedStorage:GetChildren()
print(GIS3.Value)
for i, v in pairs(game.ReplicatedStorage.Guns:GetChildren()) do
if v.Name == player.Safe.GIS3.Value then
v:Clone().Parent = player.Backpack
player.Safe.GIS3.Value = "Nothing"
end
end
end)
game.ReplicatedStorage.Taking4.OnServerEvent:Connect(function(player)
local Gs = game.ReplicatedStorage:GetChildren()
print(GIS4.Value)
for i, v in pairs(game.ReplicatedStorage.Guns:GetChildren()) do
if v.Name == player.Safe.GIS4.Value then
v:Clone().Parent = player.Backpack
player.Safe.GIS4.Value = "Nothing"
end
end
end)
game.ReplicatedStorage.Taking5.OnServerEvent:Connect(function(player)
local Gs = game.ReplicatedStorage:GetChildren()
print(GIS5.Value)
for i, v in pairs(game.ReplicatedStorage.Guns:GetChildren()) do
if v.Name == player.Safe.GIS5.Value then
v:Clone().Parent = player.Backpack
player.Safe.GIS5.Value = "Nothing"
end
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local UserId = player.UserId
local data = player.Safe.GIS.Value
local data2 = player.Safe.GIS2.Value
local data3 = player.Safe.GIS3.Value
local data4 = player.Safe.GIS4.Value
local data5 = player.Safe.GIS5.Value
GISS:SetAsync(UserId, data)
GISS2:SetAsync(UserId, data2)
GISS3:SetAsync(UserId, data3)
GISS4:SetAsync(UserId, data4)
GISS5:SetAsync(UserId, data5)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.