Advertisement
Cakey3101

Chao Inventory

May 13th, 2025
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.93 KB | Source Code | 0 0
  1. local Players = game:GetService("Players")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local RunService = game:GetService("RunService")
  4. local TweenService = game:GetService("TweenService")
  5. local UserInputService = game:GetService("UserInputService")
  6.  
  7. local TweenGui = require(script.Parent.TweenGui)
  8. local Module3D = require(ReplicatedStorage.Libs.Module3D)
  9.  
  10. local Player = Players.LocalPlayer
  11. local PlayerGui = Player.PlayerGui
  12.  
  13. local OpenButton = PlayerGui:WaitForChild("Main").Right.Chaos
  14.  
  15. local Gui = PlayerGui:WaitForChild("ChaoInventory")
  16. local Frame = Gui.Frame
  17.  
  18. local Exit = Frame.Exit
  19.  
  20. local PetsEquippedLabel = Frame.PetsEquipped
  21.  
  22. local Info = Frame.Info
  23. local DisplayPet = Info.DisplayPet
  24. local EquipButton = Info.Equip
  25. local DeleteButton = Info.Delete
  26.  
  27. local PetNameDisplayInfo = Info.PetName
  28.  
  29. local Container = Frame.Container
  30.  
  31. local SelectedTemplate = nil
  32.  
  33. local function OnEquip()
  34.     if SelectedTemplate ~= nil then
  35.         if SelectedTemplate:FindFirstChild("Equipped").Value == false then
  36.             local Result = ReplicatedStorage.Remotes.Chaos.EquipChao:InvokeServer(SelectedTemplate.Name)
  37.  
  38.             if Result == "Equip" then
  39.                 Info.Visible = true
  40.                 SelectedTemplate.Checkmark.Visible = true
  41.                 SelectedTemplate.LayoutOrder = -1
  42.                 EquipButton.Title.Text = "Unequip"
  43.                 EquipButton.BackgroundColor3 = Color3.fromRGB(232, 70, 70)
  44.                 SelectedTemplate:FindFirstChild("Equipped").Value = true
  45.             elseif Result == "Unequip" then
  46.                 SelectedTemplate.Checkmark.Visible = false
  47.                 SelectedTemplate.LayoutOrder = 0
  48.                 Info.Visible = true
  49.                 EquipButton.Title.Text = "Equip"
  50.                 EquipButton.BackgroundColor3 = Color3.fromRGB(70, 232, 70)
  51.                 SelectedTemplate:FindFirstChild("Equipped").Value = false
  52.             end
  53.         else
  54.             local Result = ReplicatedStorage.Remotes.Chaos.UnequipChao:InvokeServer(SelectedTemplate.Name)
  55.  
  56.             if Result == true then
  57.                 SelectedTemplate.Checkmark.Visible = false
  58.                 SelectedTemplate.LayoutOrder = 0
  59.                 Info.Visible = true
  60.                 EquipButton.Title.Text = "Equip"
  61.                 EquipButton.BackgroundColor3 = Color3.fromRGB(70, 232, 70)
  62.                 SelectedTemplate:FindFirstChild("Equipped").Value = false
  63.             end
  64.         end
  65.     end
  66. end
  67.  
  68. local function DeletePet()
  69.     if SelectedTemplate ~= nil then
  70.         ReplicatedStorage.Remotes.Chaos.DeleteChao:FireServer(SelectedTemplate.Name)
  71.        
  72.         SelectedTemplate:Destroy()
  73.         SelectedTemplate = nil
  74.         Info.Visible = false
  75.     end
  76. end
  77.  
  78. local function TemplatePressed(Template)
  79.     SelectedTemplate = Template
  80.     if SelectedTemplate:FindFirstChild("Equipped").Value == true then
  81.         SelectedTemplate.Checkmark.Visible = true
  82.         SelectedTemplate.LayoutOrder = -1
  83.         Info.Visible = true
  84.         EquipButton.Title.Text = "Unequip"
  85.         EquipButton.BackgroundColor3 = Color3.fromRGB(232, 70, 70)
  86.     else
  87.         SelectedTemplate.Checkmark.Visible = false
  88.         SelectedTemplate.LayoutOrder = 0
  89.         Info.Visible = true
  90.         EquipButton.Title.Text = "Equip"
  91.         EquipButton.BackgroundColor3 = Color3.fromRGB(70, 232, 70)
  92.     end
  93.     PetNameDisplayInfo.Text = Template.Name
  94.  
  95.     for i, v in pairs(DisplayPet:GetChildren()) do
  96.         if v:IsA("ViewportFrame") then
  97.             v:Destroy()
  98.         end
  99.     end
  100.  
  101.     Info.RingMultiplier.Text = `X{ReplicatedStorage.Chaos:FindFirstChild(Template.Name, true).RingMultiplier.Value}`
  102.  
  103.     local ChaoModel = Module3D:Attach3D(DisplayPet, ReplicatedStorage.Chaos:FindFirstChild(Template.Name, true):Clone())
  104.     ChaoModel:SetDepthMultiplier(1.2)
  105.     ChaoModel.Camera.FieldOfView = 5
  106.     ChaoModel.Visible = true
  107.  
  108.     RunService.PreRender:Connect(function()
  109.         ChaoModel:SetCFrame(CFrame.Angles(0, tick() * 2 % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
  110.     end)
  111. end
  112.  
  113. _G.NewTemplate = function(ChaoName)
  114.     local NewTemplate = Container.Template:Clone()
  115.     NewTemplate.Name = ChaoName
  116.     NewTemplate.Visible = true
  117.     NewTemplate.Parent = Container
  118.  
  119.     local ChaoModel = Module3D:Attach3D(NewTemplate.Display, ReplicatedStorage.Chaos:FindFirstChild(ChaoName, true):Clone())
  120.     ChaoModel:SetDepthMultiplier(1.2)
  121.     ChaoModel.Camera.FieldOfView = 5
  122.     ChaoModel.Visible = true
  123.  
  124.     RunService.PreRender:Connect(function()
  125.         ChaoModel:SetCFrame(CFrame.Angles(0, tick() * 2 % (math.pi * 2), 0) * CFrame.Angles(math.rad(-10), 0, 0))
  126.     end)
  127.  
  128.     NewTemplate.MouseButton1Click:Connect(function()
  129.         TemplatePressed(NewTemplate)
  130.     end)
  131. end
  132.  
  133. OpenButton.MouseButton1Click:Connect(function()
  134.     if Gui.Enabled == true then
  135.         TweenGui.CloseGui(Gui, Frame)
  136.     else
  137.         TweenGui.OpenGui(Gui, Frame)
  138.     end
  139. end)
  140.  
  141. Exit.MouseButton1Click:Connect(function()
  142.     TweenGui.CloseGui(Gui, Frame)
  143. end)
  144.  
  145. EquipButton.MouseButton1Click:Connect(function()
  146.     OnEquip()
  147. end)
  148.  
  149. DeleteButton.MouseButton1Click:Connect(function()
  150.     DeletePet()
  151. end)
  152.  
  153. task.wait(2)
  154.  
  155. for _, Chao in Player:WaitForChild("Chaos"):GetChildren() do
  156.     _G.NewTemplate(Chao.Name)
  157. end
  158.  
  159. while task.wait(0.05) do
  160.     pcall(function()
  161.         PetsEquippedLabel.Text = `{#workspace.PlayerChaos:FindFirstChild(Player.Name):GetChildren()} / {Player.Values.MaxChaosEquipped.Value} Chaos Equipped!`
  162.     end)
  163. end
Tags: robloxstudio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement