I have modified some stuff from the store of my game, i can’t remember what i modified and the “Perks” store got broken, here are the scripts:
--Fire event
wait(1)
local player = game.Players.LocalPlayer
for i,Buttons in pairs(script.Parent.PerksFrame:GetChildren()) do
local ImageButton = Buttons:FindFirstChild("ImageButton")
if ImageButton then
ImageButton.MouseButton1Down:connect(function()
local HasBought = Buttons:FindFirstChild("HasBought")
if HasBought then
if HasBought.Value == true then
game.ReplicatedStorage.AddGearFromStore:FireServer(Buttons.Name)
else
local Cost = Buttons:FindFirstChild("Cost")
if Cost then
local leaderstats = player:FindFirstChild("StatsValues")
if leaderstats then
local Cash = leaderstats:FindFirstChild("Nubits")
if Cash then
if Cash.Value >= Cost.Value then
HasBought.Value = true
game.ReplicatedStorage.AddGearFromStore:FireServer(Buttons.Name)
game.ReplicatedStorage.SubCash:FireServer(Cost.Value)
end
end
end
end
end
end
end)
end
end
--Give player tool
function onwin(player,Tool)
local Gear = game.Lighting.Gameitems:FindFirstChild(Tool)
if Gear then
local Backpack = player:FindFirstChild("Backpack")
local StarterGear = player:FindFirstChild("StarterGear")
if StarterGear or Backpack or StarterGear and Backpack then
for i,clearStoreItems in pairs(StarterGear:GetChildren()) do
local Tool = game.Lighting.Gameitems:FindFirstChild(clearStoreItems.Name)
if Tool then
clearStoreItems:Destroy()
end
end
for i,clearStoreItems in pairs(Backpack:GetChildren()) do
local Tool = game.Lighting.Gameitems:FindFirstChild(clearStoreItems.Name)
if Tool then
clearStoreItems:Destroy()
end
end
local char = game.Workspace:FindFirstChild(player.Name)
if char then
for i,clearStoreItems in pairs(char:GetChildren()) do
if clearStoreItems.ClassName == "Tool" then
local Tool = game.Lighting.Gameitems:FindFirstChild(clearStoreItems.Name)
if Tool then
clearStoreItems:Destroy()
end
end
end
end
local findif = StarterGear:FindFirstChild(Gear.Name)
if findif then
else
Gear:Clone().Parent = StarterGear
Gear:Clone().Parent = Backpack
end
local OwnedStoreItems = player:FindFirstChild("OwnedStoreItems")
if OwnedStoreItems then
local Findif = OwnedStoreItems:FindFirstChild(Gear.Name)
if Findif then
else
local newitem = Instance.new("Folder",OwnedStoreItems)
newitem.Name = Gear.Name
end
end
end
end
end
game.ReplicatedStorage.AddGearFromStore.OnServerEvent:connect(onwin)
Sorry by the script being to big, i didn’t made this script, and i also can’t understand this, and you can take your time to see the script and tell me what is wrong, i repeat, take the time to see this, cause this script is very long. Thanks