Things I’ve noticed:
Use of pairs() and ipairs() → Though not incorrect nor a problem, it’s just better to use generic iteration.
so for _, rank in ranks do and for i, fusion in fusionData do
This is most definitely a logic error, You’ll need to do some debugging in your code, as I’m not fully aware of how you’re handling this, and there a few missing pieces you didn’t include
Run print statements in your code at important sections to see what’s happening and what exactly it’s doing.
@snoobi77333 and @deIuxor, I have not authority on the devforum, but in the official rules it also says “Keep the discussion within the subject of the topic, if you want to change the subject, create a new topic.”
Posting the rules and calling him out on his behavior is not staying on subject nor in the rules. “If you see improper use of DevForum, please flag, the post for the Developer Engagement Team to handle” not “If you see improper use of DevForum, call them out and instigate a argument.”
It’s a helpful gesture to remind him to follow them and on how to use the devforum, but roblox can also do that by just warning/notifying him, we aren’t the moderators of the devforum, don’t act like it.
That’s for you to find out, you built this system, you need to understand the logic and how it works, there is only so much I can do from just looking at the provided code snippets.
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Buy = script.Parent.Parent.BuyFusion
local priceLabel = script.Parent.Parent.Cost_Title
local boostLabel = script.Parent.Parent.YourBoost
local yourFusionLabel = script.Parent.Parent.YourClass_Title
local nextBoostLabel = script.Parent.Parent.NextBoostText
local nextFusionTitleLabel = script.Parent.Parent.NextClass_Title
local price2 = script.Parent.Parent.PriceText
local nextFusionLabel = script.Parent.Parent.NextClassName2
local yourFusionName = script.Parent.Parent.ClassNameText
-- Таблицы с данными о фушионах и бустах
local fusionData = {
{name = "Werewolf", price = 500, boost = 2, owned = false},
{name = "Minotaur", price = 1000, boost = 4, owned = false},
{name = "Dog", price = 5000, boost = 8, owned = false},
{name = "Lola", price = 10000, boost = 16, owned = false}
}
-- Начальное значение текущего фушиона
local currentFusion = "Werewolf"
-- Функция для получения текущего и следующего фушиона
local function getCurrentAndNextFusion()
for i, fusion in ipairs(fusionData) do
if fusion.name == currentFusion then
local nextFusion = fusionData[i + 1]
return fusion, nextFusion
end
end
return nil, nil
end
-- Обновление отображаемой информации о фушионах
local function updateFusionDisplay()
local currentFusionData, nextFusionData = getCurrentAndNextFusion()
if currentFusionData then
price2.Text = "Price: " .. currentFusionData.price .. " price"
boostLabel.Text = "💪: x" .. currentFusionData.boost
yourFusionName.Text = "Your Fusion: " .. currentFusionData.name
if nextFusionData then
nextBoostLabel.Text = "Next Boost: x" .. nextFusionData.boost
nextFusionLabel.Text = "Next Fusion: " .. nextFusionData.name
else
nextBoostLabel.Text = "Next Boost: MAX"
nextFusionTitleLabel.Text = "Next Fusion: MAX"
nextFusionLabel.Text = "MAX"
price2.Text = ""
end
end
end
-- Инициализация отображения
updateFusionDisplay()
-- Обработчик нажатия кнопки
script.Parent.MouseButton1Click:Connect(function()
local currentFusionData, nextFusionData = getCurrentAndNextFusion()
if currentFusionData then
-- Проверка total power
local totalPower = LocalPlayer:FindFirstChild("TotalPower")
if totalPower and totalPower.Value >= currentFusionData.price then
-- Проверка, был ли фушион уже куплен
if not currentFusionData.owned then
-- Вызываем событие на сервере для покупки
game:GetService("ReplicatedStorage").FusionUp:FireServer(currentFusion)
-- Отметить текущий фушион как обладаемый
currentFusionData.owned = true
-- Обновление текущего фушиона на следующий
currentFusion = nextFusionData and nextFusionData.name or currentFusion
-- Уменьшить Total Power игрока
totalPower.Value = totalPower.Value - currentFusionData.price
-- Обновление отображения
updateFusionDisplay()
else
print("Вы уже обладаете этим фушионом.")
end
else
print("Недостаточно total power для покупки фушиона.")
end
end
end)
I solved all the problems now the problem is different I want the script to check what kind of fusion the player has so that he doesn’t buy fusion again and I would like it to be saved when he re-enters the server What will be the next boost what is his boost what will be the price and what is his fushion and what will be the next one