How to make a working Bin Roblox Tutorial

Model: BinModel.rbxm (24.6 KB)

Server Script:

local DeleteItems = game.ReplicatedStorage.BinSystem:FindFirstChild("Bins")


DeleteItems.OnServerEvent:Connect(function(player)
	for i, v in ipairs(player.Backpack:GetDescendants()) do
		v:Destroy()
	end
end)

Local Script:

local BinDetector = game.Workspace.Bins.Bin.Detector
local StarterGui = game:GetService("StarterGui")
local Debounce = false
local DeleteItems = game.ReplicatedStorage.BinSystem:FindFirstChild("Bins")


local bindable = Instance.new("BindableFunction")


function bindable.OnInvoke(response)
	DeleteItems:FireServer()
end



local function Notification()
	StarterGui:SetCore("SendNotification", {
		Title = "ALERT",
		Text = "Would you like to clear your inventory?",
		Button1 = "YES",
		Callback = bindable
	})
end



BinDetector.Touched:Connect(function(Part)
	if Debounce == false then
		Debounce = true
		local PartParent = Part.Parent

		local humanoid = PartParent:FindFirstChildWhichIsA("Humanoid")

		if humanoid then
			Notification()
			wait(8)
			Debounce = false
		end
	end
end)

This topic was automatically closed 1 minute after the last reply. New replies are no longer allowed.