0% found this document useful (0 votes)
23 views4 pages

Message

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Message

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

local inventoryFrame = script.

Parent

local startgui = game:GetService("StarterGui")

local Players = game:GetService("Players")


local Player = Players.LocalPlayer
local mouse = Player:GetMouse()
local equipDb = false

local DataManagementModule = require(script.Parent.DataManagementModule)


local ItemsModule = require(script.Parent.ItemsModule)

local itemFolder = game:GetService("ReplicatedStorage").Common.Items


local runService = game:GetService("RunService")

local remotes = script.Parent.Parent.Remotes


local inventoryRemote = remotes.InventoryRemote

local inventoryLoader = {}

function createViewport(template,v)
local viewport = template.Viewport
local camera = Instance.new("Camera",viewport)
local model = Instance.new("Model",viewport)
local handleClone = itemFolder[v.Name].Handle:Clone()
handleClone.Anchored = true
handleClone.Parent = model
model.PrimaryPart = handleClone
viewport.CurrentCamera = camera
camera.CFrame = handleClone.CFrame*CFrame.new(Vector3.new(0,0,-
5),Vector3.new(0,0,0))
template.ItemName.Visible = true
template.ItemName.Text = v.Name
end

function setTemplateColor(template,itemName)
local connection
local lastTick = tick()
if ItemsModule[itemName].Rarity == "Common" then
template.Bg.UIStroke.UIGradient.Enabled = false
template.Bg.UIStroke.Color = Color3.new(0.705882, 0.705882, 0.705882)
elseif ItemsModule[itemName].Rarity == "Rare" then
template.Bg.UIStroke.UIGradient.Enabled = false
template.Bg.UIStroke.Color = Color3.new(0, 1, 0)
elseif ItemsModule[itemName].Rarity == "Epic" then
template.Bg.UIStroke.UIGradient.Enabled = false
template.Bg.UIStroke.Color = Color3.new(0.333333, 0, 1)
elseif ItemsModule[itemName].Rarity == "Legendary" then
template.Bg.UIStroke.UIGradient.Enabled = true
template.Bg.UIStroke.UIGradient.Color =
ColorSequence.new({ColorSequenceKeypoint.new(0,Color3.fromRGB(255, 0,
0)),ColorSequenceKeypoint.new(0.1,Color3.fromRGB(85, 170,
255)),ColorSequenceKeypoint.new(0.2,Color3.fromRGB(255, 255,
0)),ColorSequenceKeypoint.new(0.3,Color3.fromRGB(0, 255,
0)),ColorSequenceKeypoint.new(0.4,Color3.fromRGB(255, 170,
255)),ColorSequenceKeypoint.new(0.5,Color3.fromRGB(255, 0,
0)),ColorSequenceKeypoint.new(0.6,Color3.fromRGB(85, 170,
255)),ColorSequenceKeypoint.new(0.7,Color3.fromRGB(255, 255,
0)),ColorSequenceKeypoint.new(0.85,Color3.fromRGB(0, 255,
0)),ColorSequenceKeypoint.new(1,Color3.fromRGB(255, 170, 255))})
elseif ItemsModule[itemName].Rarity == "Treasure" then
template.Bg.UIStroke.UIGradient.Enabled = true
template.Bg.UIStroke.UIGradient.Color =
ColorSequence.new({ColorSequenceKeypoint.new(0,Color3.fromRGB(0, 0,
0)),ColorSequenceKeypoint.new(0.1,Color3.fromRGB(255, 255,
255)),ColorSequenceKeypoint.new(0.2,Color3.fromRGB(0, 0,
0)),ColorSequenceKeypoint.new(0.3,Color3.fromRGB(255, 255,
255)),ColorSequenceKeypoint.new(0.4,Color3.fromRGB(0, 0,
0)),ColorSequenceKeypoint.new(0.5,Color3.fromRGB(0, 0,
0)),ColorSequenceKeypoint.new(0.6,Color3.fromRGB(255, 255,
255)),ColorSequenceKeypoint.new(0.7,Color3.fromRGB(0, 0,
0)),ColorSequenceKeypoint.new(0.85,Color3.fromRGB(255, 255,
255)),ColorSequenceKeypoint.new(1,Color3.fromRGB(0, 0, 0))})
end
--border effect
if ItemsModule[itemName].Rarity == "Treasure" then
connection = runService.PostSimulation:Connect(function(deltaTime)
if tick()-lastTick > 0.1 and
template.Bg.UIStroke.UIGradient.Rotation < 1000 then
template.Bg.UIStroke.UIGradient.Rotation += 1
lastTick = tick()
elseif template.Bg.UIStroke.UIGradient.Rotation >= 1000 then
template.Bg.UIStroke.UIGradient.Rotation = 0
end
end)
elseif ItemsModule[itemName].Rarity == "Legendary" then
connection = runService.PostSimulation:Connect(function(deltaTime)
if tick()-lastTick > 0.1 and
template.Bg.UIStroke.UIGradient.Rotation < 1000 then
template.Bg.UIStroke.UIGradient.Rotation += 1
lastTick = tick()
elseif template.Bg.UIStroke.UIGradient.Rotation >= 1000 then
template.Bg.UIStroke.UIGradient.Rotation = 0
end
end)
end
-- end of border effect
return connection
end

function inventoryLoader.loadInventory(scroll)
local PlayerGui = Player.PlayerGui
local FramesGui = PlayerGui.FramesGUI
local InventoryFrame = FramesGui.InventoryFrame
local getInventory = Player:WaitForChild("Inventory"):GetChildren()
for _,v in ipairs(getInventory) do
local template = nil
local templateColorConnection
inventoryRemote:FireServer(v.Name,v.Equipped.Value)
if v.Value >= 1 then
template = script.ItemTemplate:Clone()
template.LayoutOrder = v.Value
template.Parent = scroll
template.Name = v.Name
templateColorConnection = setTemplateColor(template,v.Name)
if itemFolder[v.Name]:FindFirstChild("Handle") then
createViewport(template,v)
else
template.EquipButton.Text = v.Name
end
template.EquipButton.MouseButton1Click:Connect(function()
Player.Inventory[v.Name].Equipped.Value = not
Player.Inventory[v.Name].Equipped.Value
if Player.Inventory[v.Name].Equipped.Value == true and
equipDb == false then
equipDb = true
inventoryRemote:FireServer(v.Name,true)
wait(.25)
equipDb = false
elseif Player.Inventory[v.Name].Equipped.Value == false
then
inventoryRemote:FireServer(v.Name,false)
end
end)
template.Amount.Text = "x"..v.Value
template.Visible = true
else
if template then
if templateColorConnection ~= nil then
templateColorConnection:Disconnect()
end
template:Destroy()
remotes.InventoryRemote:FireServer(v.Name,false)
Player.Inventory[v.Name].Equipped.Value = false
end
end
-- makes the color border rotation dont run when inventory
invisible/closed
if InventoryFrame.Visible == false then
if templateColorConnection ~= nil then
templateColorConnection:Disconnect()
end
else
if template then
templateColorConnection = setTemplateColor(template,v.Name)
end
end
InventoryFrame:GetPropertyChangedSignal("Visible"):Connect(function()
if InventoryFrame.Visible == false then
if templateColorConnection ~= nil then
templateColorConnection:Disconnect()
end
else
if template then
templateColorConnection =
setTemplateColor(template,v.Name)
end
end
end) ---------------------------- end of border stop script
v.Changed:Connect(function()
if v.Value >= 1 then
if template then -- removes the old template
template:Destroy()
end
template = script.ItemTemplate:Clone()
template.LayoutOrder = v.Value
template.Parent = scroll
template.Name = v.Name
templateColorConnection = setTemplateColor(template,v.Name)
if itemFolder[v.Name]:FindFirstChild("Handle") then
createViewport(template,v)
else
template.EquipButton.Text = v.Name
end
template.EquipButton.MouseButton1Click:Connect(function()
Player.Inventory[v.Name].Equipped.Value = not
Player.Inventory[v.Name].Equipped.Value
if Player.Inventory[v.Name].Equipped.Value == true
and equipDb == false then
equipDb = true
inventoryRemote:FireServer(v.Name,true)
wait(.25)
equipDb = false
elseif Player.Inventory[v.Name].Equipped.Value ==
false then
inventoryRemote:FireServer(v.Name,false)
end
end)
template.Amount.Text = "x"..v.Value
template.Visible = true
else
if template then
if templateColorConnection ~= nil then
templateColorConnection:Disconnect()
end
template:Destroy()
remotes.InventoryRemote:FireServer(v.Name,false)
Player.Inventory[v.Name].Equipped.Value = false
end
end
end)
end
end

return inventoryLoader

You might also like