Also, if value == 1, buy button needs to be turned inactive and change its color, but it doesnt work:
local result = UgradeSaveRemote:InvokeServer(isUpgradeBoughtValue, Item.Name)
if result == true then
Frame.TextButton.Active = false
Frame.TextButton.BackgroundColor3 = Color3.new(0.462745, 0.462745, 0)
Frame.TextButton.Active = false
end
Do i need to create a new remote event to do this?
-- Upgrades display
for i, Item in pairs(UpgradesModule.Upgrades) do
local Frame = TemplateUpgrade:Clone()
local isUpgradeBoughtValue = Player.UpgradeStatus[Item.Name].Value
local UpgradeSaveName = Player.UpgradeStatus[Item.Name]
Frame.Parent = UpgradesFrame.UpgradesSection.ScrollingFrame
Frame.Name = tostring(i)
Frame.ImageLabel.Image = Item.Image
Frame.UpgradeName.Text = Item.Name
Frame.MultiplierAmount.Text = tostring(Item.Multiplier)..'x'
Frame.CostAmount.Text = tostring(Item.Cost)..'👅'
-- Upgrades purchasing
Frame.TextButton.MouseButton1Click:Connect(function()
local Product = nil
for i, Item in pairs(UpgradesModule.Upgrades) do
if Item.Name == Frame.UpgradeName.Text then
Product = Item
end
end
if Freakiness.Value >= Product.Cost and isUpgradeBoughtValue == false then
-- Adding multiplier
UpgradePurchased:FireServer(Product)
Frame.TextButton.Text = 'Bought'
Frame.TextButton.BackgroundColor3 = Color3.new(0.462745, 0.462745, 0)
Frame.TextButton.Active = false
isUpgradeBoughtValue = true
local result = UgradeSaveRemote:InvokeServer(isUpgradeBoughtValue, Item.Name)
if result == true then
Frame.TextButton.Active = false
Frame.TextButton.BackgroundColor3 = Color3.new(0.462745, 0.462745, 0)
Frame.TextButton.Active = false
end
end
end)
end
then you will need to save the value with datastores and when creating the upgrade buttons check if its already bought
-- Upgrades display
for i, Item in pairs(UpgradesModule.Upgrades) do
local Frame = TemplateUpgrade:Clone()
local isUpgradeBoughtValue = Player.UpgradeStatus[Item.Name].Value
local UpgradeSaveName = Player.UpgradeStatus[Item.Name]
Frame.Parent = UpgradesFrame.UpgradesSection.ScrollingFrame
Frame.Name = tostring(i)
Frame.ImageLabel.Image = Item.Image
Frame.UpgradeName.Text = Item.Name
Frame.MultiplierAmount.Text = tostring(Item.Multiplier)..'x'
Frame.CostAmount.Text = tostring(Item.Cost)..'👅'
if isUpgradeBoughtValue == true then
Frame.TextButton.Active = false
Frame.TextButton.BackgroundColor3 = Color3.new(0.462745, 0.462745, 0)
Frame.TextButton.Active = false
end
-- Upgrades purchasing
Frame.TextButton.MouseButton1Click:Connect(function()
local Product = nil
for i, Item in pairs(UpgradesModule.Upgrades) do
if Item.Name == Frame.UpgradeName.Text then
Product = Item
end
end
if Freakiness.Value >= Product.Cost and isUpgradeBoughtValue == false then
-- Adding multiplier
UpgradePurchased:FireServer(Product)
Frame.TextButton.Text = 'Bought'
Frame.TextButton.BackgroundColor3 = Color3.new(0.462745, 0.462745, 0)
Frame.TextButton.Active = false
isUpgradeBoughtValue = true
local result = UgradeSaveRemote:InvokeServer(isUpgradeBoughtValue, Item.Name)
end
end)
end