Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Place this serverscript in ServerScriptService
- --(DO NOT TOUCH ANYTHING BELOW)
- local RS = game:GetService('ReplicatedStorage')
- local RemoteEvent = RS:WaitForChild('ToolEvent')
- game.Players.PlayerAdded:Connect(function(Player)
- local Folder = Instance.new('Folder')
- Folder.Name = Player.Name.. "'s Tools"
- Folder.Parent = game.ReplicatedStorage
- end)
- local function FireRemote(plr,val,item)
- if val == 'steppedOn' then
- local Character = plr.Character
- for i,v in pairs(Character:GetChildren()) do
- if v:IsA('Tool') then
- v.Parent = game.ReplicatedStorage[plr.Name.. "'s Tools"] -- if you have an equipped tool, it will place it in the folder that's created for our tools.
- end
- end
- for i,v in pairs(plr.Backpack:GetChildren()) do
- if v.Name ~= item.Name then
- if game.ReplicatedStorage[plr.Name.. "'s Tools"] then
- v.Parent = game.ReplicatedStorage[plr.Name.. "'s Tools"] -- then takes the rest of our tools that are in our backpack and places it in the folder
- end
- end
- end
- local NewWEAPON = item:Clone() -- "item" is our tool that we get from ReplicatedStorage in the LocalScript
- NewWEAPON.Parent = plr.Backpack
- Character.Humanoid:EquipTool(NewWEAPON)
- elseif val == 'steppedOff' then
- local Character = plr.Character
- for i,v in pairs(Character:GetChildren()) do
- if v then
- if v:IsA('Tool') then
- if v.Name == item.Name then
- v:Destroy()
- end
- end
- end
- end
- for i,v in pairs(plr.Backpack:GetChildren()) do
- if v then
- if v:IsA('Tool') then
- if v.Name == item.Name then
- v:Destroy()
- end
- end
- end
- end
- for i,tool in pairs(game.ReplicatedStorage[plr.Name.. "'s Tools"]:GetChildren()) do -- now we get all our tools back
- tool.Parent = plr.Backpack
- end
- end
- end
- RemoteEvent.OnServerEvent:Connect(FireRemote)
- game.Players.PlayerRemoving:Connect(function(Player)
- if game.ReplicatedStorage:FindFirstChild(Player.Name.. "'s Tools") then
- game.ReplicatedStorage:FindFirstChild(Player.Name.. "'s Tools"):Destroy()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement