Having Problem with Gear Script

  1. What do you want to achieve? Keep it simple and clear!
    How to fix the gear script i created.

  2. What is the issue? Include screenshots / videos if possible!
    The problem is that i have script for like a catalog gears and it seems to not be working anymore.


    https://gyazo.com/c132e020e7ad92be4d32969df0b0c514
    https://gyazo.com/8afd9f073d34c46e29300eff190e111a

How it was supposed to look-
https://gyazo.com/44f7f58897065bfc2cfc1b526f0b61ba

  1. What solutions have you tried so far?
    I haven’t tried any solutions so that i do not mess the script up.

I do not need a full script, just a bit of help on it so i can finish this up.

What about it doesn’t work? Are there any errors? Have you tried debugging using prints or breakpoints?
We need more context than just ‘it doesn’t work’.

When I test the game it does this: https://gyazo.com/d135b03f24bda1cdd46f4fd70cea4673

When really it is supposed to do what I showed up in the description.

It used to work before but I feel like i did something wrong but i cannot seem to find the problem.

The Script seemingly looks fine however it may be the LocalScript that’ll be the problem.
Are you able to give the LocalScript here rather than a gif? It’s tough to read & the main part isn’t shown.
Remember to format:
```
–code
```

local Gear = game:GetService('ReplicatedStorage').GiveGear
local Get = game:GetService('ReplicatedStorage').Get
-- Filter Functions

function Updated(val1,val2)
	if val1 and val2 then
		val1 = string.match(val1['UpdatedDate'],'%b()')
		val1 = val1:sub(2,#val1-1)
		
		val2 = string.match(val2['UpdatedDate'],'%b()')
		val2 = val1:sub(2,#val2-1)
		print(val1,val2)
		
		return val1 < val2
	elseif val1 then return false else return true
	end
end

function Created(val1,val2)
	if val1 and val2 then
		val1 = string.match(val1['CreatedDate'],'%b()')
		val1 = val1:sub(2,#val1-1)
		
		val2 = string.match(val2['CreatedDate'],'%b()')
		val2 = val1:sub(2,#val2-1)
		print(val1,val2)
		
		return val1 < val2
	elseif val1 then return val1 elseif val2 then return val2
	end
end





function Search(name)
	local found = {}
	for i,v in pairs(Catalog) do
		if v.Name:lower():find(name:lower()) then
			table.insert(found,v)
		end
	end
	return found
end

local Container = script.Parent.Frame.Frame.Container
local SearchBar = script.Parent.Frame.Searchbox
local Filters = script.Parent.Frame.Filter
--v.Position = UDim2.new(i/(#stuff.Background)-(1/#stuff.Background),7,0,5)
function Add(tbl)
	
	for i,v in pairs(tbl) do
		Container.CanvasSize = UDim2.new(1,0,0,(180*math.floor(i/3))+180)
		local Row = math.floor(#Container:GetChildren()/3)
		local Pos = math.fmod(#Container:GetChildren(),3)
		local CanMove = (Container.AbsoluteSize.X-30)/3
		local Base = Instance.new('TextButton',Container)
		Base.Size = UDim2.new(0,136,0,136)
		Base.BackgroundColor3 = Color3.new(1,1,1)
		Base.BorderColor3 = Color3.new(1,1,1)
		Base.Position = UDim2.new(0,20+Pos*CanMove,0,Row*180)
		Base.Text = ''
		Base.ClipsDescendants = true
		Base.BorderSizePixel = 2
		Base.MouseButton1Click:connect(function()
			Gear:FireServer(v['AssetId'])
			spawn(function()
				local x = Instance.new('Sound',workspace.CurrentCamera)
				x.SoundId = 'rbxassetid://3359534883'
				x.TimePosition = 1
				x:Play()
			end)
		end)
		
		local Image = Instance.new('ImageLabel',Base)
		local Camera = Instance.new('Camera',Image)
		if not game:GetService('ReplicatedStorage').Loaded:FindFirstChild(v['AssetId']) then
			Get:FireServer(v['AssetId'])
		end
		Image.BackgroundTransparency = 1
		Image.Size = UDim2.new(1,0,1,0)
		local Tool = game:GetService('ReplicatedStorage').Loaded:WaitForChild(v['AssetId'])
		Image.Image = Tool.TextureId
		local Name = Instance.new('TextLabel',Base)
		Name.Position = UDim2.new(0,0,1,-10)
		Name.Size = UDim2.new(1,0,0,10)
		Name.BackgroundTransparency = 1
		Name.Text = v['Name']
		Name.ZIndex = 2
		if Name.TextBounds.X > Name.AbsoluteSize.X then
			Name.Text = Name.Text:sub(1,#Name.Text-#Name.Text/3)..' ...'
		end
		
		if v["IsForSale"] then
			local x = Instance.new('TextLabel',Base)
			x.Size = UDim2.new(0,20,0,10)
			x.BackgroundTransparency = 1
			x.Text = 'OffSale'
			x.TextColor3 = Color3.new(1,0,0)
			x.TextXAlignment = 'Left'
		end
		
		local Roux = Instance.new('TextLabel',Base)
		Roux.Size = UDim2.new(1,0,0,10)
		Roux.TextXAlignment = 'Right'
		Roux.BackgroundTransparency = 1
		if not v["Price"] then
			Roux.Text = 'Broken'
			else
			Roux.Text = v["Price"]
		end
		
	end
end

function rrandom()
	local tbl = {Catalog[1]}
	for i,v in pairs(Catalog) do
		math.randomseed(tick())
		table.insert(tbl,math.random(1,#tbl or 1),v)
	end
	print(#tbl)
	Add(tbl)
end

function PriceToLow()
	local tbl = {}
	for i,v in pairs(Catalog) do
		table.insert(tbl,v['Price'])
	end
	local sorted = {}
	
	for i,v in pairs(tbl) do
		
	end
	Add(tbl)
end

-- Filter Events

Filters.MouseButton1Click:connect(function()
	Filters.ClipsDescendants = not Filters.ClipsDescendants
end)
Filters.Random.MouseButton1Click:connect(function()
	Container:ClearAllChildren()
	rrandom()
end)
Filters.HighToLow.MouseButton1Click:connect(function()
	Container:ClearAllChildren()
	table.sort(Catalog,PriceToLow)
	Add(Catalog)
end)
Filters.LowToHigh.MouseButton1Click:connect(function()
	Container:ClearAllChildren()
	PriceToLow()
end)
Filters.Updated.MouseButton1Click:connect(function()
	Container:ClearAllChildren()
	table.sort(Catalog,Updated)
	Add(Catalog)
end)
Filters.Created.MouseButton1Click:connect(function()
	Container:ClearAllChildren()
	table.sort(Catalog,Created)
	Add(Catalog)
end)


SearchBar.FocusLost:connect(function(enter)
	if enter then
		print'ne'
		Container:ClearAllChildren()
	else
		print'ye'
	end
	Add(Search(SearchBar.Text))
end)


--print(#Catalog)












What is ‘Catalog’, I don’t see it defined anywhere?

I don’t mind editing over it? (too short)

Right at the top of your LocalScript, invoke your GetCatalog function and define it as ‘Catalog’:

local Catalog = game:GetService("ReplicatedStorage").GetCatalog:InvokeServer()

EDIT: Noticed it was a RemoteFunction, I’ve edited the code.


https://gyazo.com/ced525c0d2c083a4b08b54d866ac2ece
It was already like that.

So there isn’t anything you edited :confused: