Unboxing Case System

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    **Hi I need to make this unboxing system move the tool into a frame that i have called Inventory instead of the backpack/hotbar.

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried coming up with solutions with the roblox AI but its not really useful.

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.

Make a program detect when the mouse enters the SwordFrame and when it exits with InputBegan and InputEnded. If the mouse is clicked and held while the mouse is in the SwordFrame, the set the SwordFrame position to the mouse with offset, and if the mouse lets go in the Inventory, transfer the SwordFrame to the inventory

1 Like

Server script service scripts:
local Remote = game.ReplicatedStorage.CaseRemotes.BuyCase

Remote.OnServerEvent:Connect(function(Player)
Player.leaderstats.Money.Value -= 100
end)

game.Players.PlayerAdded:Connect(function(p)
local stats = Instance.new(“IntValue”)
stats.Name = “leaderstats”
stats.Parent = p

local money = Instance.new("IntValue", stats)
money.Name = "Money"

money.Value = 500

end)

scripts in my Case opening gui: local Tools = game.ServerStorage.Tools

game.ReplicatedStorage.CaseRemotes.GetItem.OnServerEvent:Connect(function(plr, item, rarity)
local UnboxedTool = Tools:FindFirstChild(item)
if UnboxedTool then
local Clone = UnboxedTool:Clone()
Clone.Parent = plr.Backpack
end
end)

local Player = game.Players.LocalPlayer
local cooldown = 1
debounce = false

local Tool = {
{Name = “ClassicSword”, Rarity = “Common”},
{Name = “Key”, Rarity = “Basic”},
{Name = “Robux”, Rarity = “Rare”},
{Name = “WaterBottle”, Rarity = “Legendary”},
}

local ToolTable = {
{tool = Tool[1], Weight = 100},
{tool = Tool[2], Weight = 60},
{tool = Tool[3], Weight = 30},
{tool = Tool[4], Weight = 15},
}

local color = {
{Rarity = “Common”, Color = Color3.fromRGB(118,118,118)},
{Rarity = “Basic”, Color = Color3.fromRGB(203, 222, 241)},
{Rarity = “Rare”, Color = Color3.fromRGB(32, 214, 255)},
{Rarity = “Legendary”, Color = Color3.fromRGB(240, 23, 255)},
}

local function returnWeight(ToolTable)
local s = 0
for i, entry in pairs(ToolTable) do
s = s + entry.Weight
end
return s
end

local function getRandomItem(ToolTable)
local randomNumber = math.random(returnWeight(ToolTable))
for i, entry in ipairs(ToolTable) do
if randomNumber <= entry.Weight then
return entry.tool
else
randomNumber = randomNumber - entry.Weight
end
end
end

script.Parent.TextButton.MouseButton1Click:Connect(function()
if Player.leaderstats.Money.Value >= 100 then
game.ReplicatedStorage.CaseRemotes.BuyCase:FireServer(Player)
if debounce == false then
script.Parent.UnboxFrame.Rarity.TextColor3 = Color3.new(1,1,1)
script.Parent.UnboxFrame.ItemName.Text = “None”

		debounce = true
		
		for count = 1,35 do
			local item = getRandomItem(ToolTable)
			local rarity = item.Rarity
			
			script.Parent.UnboxFrame.ItemName.Text = item.Name
			script.Parent.UnboxFrame.Rarity.Text = item.Rarity
			
			for i, v in ipairs(color) do
				if v.Rarity == rarity then
					script.Parent.UnboxFrame.Rarity.TextColor3 = v.Color
				end
			end
			wait(0.025)
		end
		
		local item = getRandomItem(ToolTable)	
		local name = item.Name
		local rarity = item.Rarity
		script.Parent.UnboxFrame.Rarity.Text = rarity
		script.Parent.UnboxFrame.ItemName.Text = name
		
		game.ReplicatedStorage.CaseRemotes.GetItem:FireServer(name, rarity)
		
		for i, v in ipairs(color) do
			if v.Rarity == rarity then
				script.Parent.UnboxFrame.Rarity.TextColor3 = v.Color
			end
		end
		wait(cooldown)
		debounce = false
	end
else
	script.Parent.TextButton.Text = "Not enough Money!"
	wait(1)
	script.Parent.TextButton.Text = "Buy Case [100$]"
end

end)