How to make? class system

yes the player clicks on the button his class changes

Yes, but if there is only 1 button, or is it the specification of the class that is more than one button?

Because if it’s one button, then this code seems to accomplish the purchase

yes, I have 1 button, it’s impossible to do right?

No, it is possible, but to determine the class it must be automatic.

local player = game.Players.LocalPlayer
local tp = player["TotalPower"]
local class = player.Class 
local name = script.Parent.Parent.ClassNameText
local reset = game.ReplicatedStorage.ResetStats
local setClass = game.ReplicatedStorage.AddStat
local selectedClass
local accepted = {"D-Class", "F-Class"}

script.Parent.MouseButton1Click:Connect(function()
	if class.Value == "D-Class" then
		selectedClass = "F-Class"
	end
	selectedClass = selectedClass or "D-Class"
	if table.find(selectedClass, accepted) and class.Value ~= selectedClass then
		if tp.Value >= 50 then
			setClass:FireServer("Class", selectedClass or "D-Class", "set")
			reset:FireServer()
		end
	end
end)

It automatically chooses the class, so it does not need to be typed.

Players.Lamino961.PlayerGui.Classes/Fusions.Frame.ClassesFrame.BuyBtn.LocalScript:15: invalid argument #1 to ‘find’ (table expected, got string) - Client - LocalScript:15

Typo in the code, fixed:

local player = game.Players.LocalPlayer
local tp = player["TotalPower"]
local class = player.Class 
local name = script.Parent.Parent.ClassNameText
local reset = game.ReplicatedStorage.ResetStats
local setClass = game.ReplicatedStorage.AddStat
local selectedClass
local accepted = {"D-Class", "F-Class"}

script.Parent.MouseButton1Click:Connect(function()
	if class.Value == "D-Class" then
		selectedClass = "F-Class"
	end
	selectedClass = selectedClass or "D-Class"
	if table.find(accepted, selectedClass) and class.Value ~= selectedClass then
		if tp.Value >= 50 then
			setClass:FireServer("Class", selectedClass, "set")
			reset:FireServer()
		end
	end
end)

omg ths bro i love you bro i love youuuuuuuurrrrrrr!!!

and you can help make it so that after the purchase the text changed, that is, you had a boost of 10000 from the left, it became 15k and the class name also changes, and from the right you write what class how much power is needed and what kind of boost will be

local player = game.Players.LocalPlayer
local tp = player["TotalPower"]
local class = player.Class 
local name = script.Parent.Parent.ClassNameText
local reset = game.ReplicatedStorage.ResetStats
local setClass = game.ReplicatedStorage.AddStat
local selectedClass
local accepted = {"D-Class", "F-Class"}
local boosts = {["F-Class"]=15e3, ["D-Class"]=10e3} --e3=000, 1e3 = 1000, 10e3 = 10000
local tpNeeded = {["F-Class"]=100, ["D-Class"]=50} --total power needed

script.Parent.MouseButton1Click:Connect(function()
	if class.Value == "D-Class" then
		selectedClass = "F-Class"
	end
	selectedClass = selectedClass or "D-Class"
	if table.find(accepted, selectedClass) and class.Value ~= selectedClass then
		if tp.Value >= tpNeeded[selectedClass] then
			setClass:FireServer("Class", selectedClass, "set")
			reset:FireServer()
		end
	end
	name.Text = selectedClass
	local boost = boosts[selectedClass]
	name.Text ..= " boost "..boost
end)

Is this the correct GUI to change? I don’t know where it is located.

look bro f class is the initial one it is given to the player automatically that is, the player does not buy it

Screenshot_1

I see, that was confusing since F is after D, but it’s corrected here:

local player = game.Players.LocalPlayer
local tp = player["TotalPower"]
local class = player.Class 
local name = script.Parent.Parent.ClassNameText
local reset = game.ReplicatedStorage.ResetStats
local setClass = game.ReplicatedStorage.AddStat
local selectedClass
local accepted = {"D-Class", "F-Class"}
local boosts = {["F-Class"]=1e4, ["D-Class"]=15e3} --e3=000, 1e3 = 1000, 10e3 = 10000
local tpNeeded = {["F-Class"]=0, ["D-Class"]=50} --total power needed
local desc = script.Parent.Parent.Desc

script.Parent.MouseButton1Click:Connect(function()
	if class.Value == "F-Class" then
		selectedClass = "D-Class"
	end
	selectedClass = selectedClass or "F-Class"
	if table.find(accepted, selectedClass) and class.Value ~= selectedClass then
		if tp.Value >= tpNeeded[selectedClass] then
			setClass:FireServer("Class", selectedClass, "set")
			reset:FireServer()
		end
	end
	name.Text = selectedClass
	local boost = boosts[selectedClass]
	desc.Text= " boost "..boost
end)

Now the “Desc” is changed.

thank you it works and now how to do how much the next class will cost and how much boost there will be and the name, the name of the d class, but the price is 20k total and the boost is 20k too

The price is 20k of the total power, or is it separate? The boost is adjusted by the “boost” table.

Yes that’s right now I’m sending you the location

Screenshot_1

thank you for your good help, I will do it and thank you all again if it weren’t for you, I would be here for another month waiting for an answer and you helped me in just 2 days

I have bugs right now when a player has 0 strength, he buys a class, his text changes and writes a message in the chat

hello, I created a script when a player buys a class, he teleports to the point where his spawn is located and he has an aura when I buy a class, I do not have an aura and when I buy a class with 0 strength, the text changes, can I do it so that after the purchase it changes?

aura script

local event = game.ReplicatedStorage.PromoteClass
local alertClients = game.ReplicatedStorage.ServerMessage

local abbrev = game.ReplicatedStorage.AbbrevText

event.OnServerEvent:Connect(function(player)
	

	local currentClass = player.Class.Value:gsub('-', '')
	local currentClass = player.Class.Value:gsub('-', '')
	local nextClassReq
	local nextClass
	local prev
	
	local classes = {
		"FClass",
		"DClass",
		


}		
		-- AURA STUFF --
		
		for i, v in pairs(player.Character:GetChildren()) do
			if v:IsA("BasePart") then
				for idx, value in pairs(v:GetChildren()) do
					if value:IsA("ParticleEmitter") or value:IsA("Attachment") and value:FindFirstChildWhichIsA("ParticleEmitter") then
						value:Destroy()
					end
				end
			end
		end
		
		-- ADD NEW AURA --
		
		local aura = game.ServerStorage.Powers.Auras[currentClass.."Aura"]:Clone()
		aura.Parent = player.Character
		
		for i, v in pairs(aura:GetChildren()) do
			v.Parent = player.Character[v.Name]
		end
		
		aura:Destrou()
end)

you tell me what your time zone is so that I can keep in touch with you, otherwise I’m sleeping, you’re writing, you’re sleeping, I’m writing :slight_smile: