How to make? class system

Ok, that is all I needed, so it was a problem with the server.

local event = game.ReplicatedStorage.AddStat
local alertClients = game.ReplicatedStorage.ServerMessage
local MarketPlaceService = game:GetService("MarketplaceService")

local gamepassId = 251841658
local strengthPass = 251310188
local endPass = 251310008

local mults = require(game.ServerStorage.classMults)

local function ownsgamepass(userId, gamepassId)
	local ownsGamepass
	local s,res = pcall(function()
		ownsGamepass = MarketPlaceService:UserOwnsGamePassAsync(userId, gamepassId)
	end)

	return ownsGamepass
end
event.OnServerEvent:Connect(function(player, stat, val, op)
	local value = val -- to not alter original value
	local owns = ownsgamepass(player.UserId, gamepassId)
	if (stat == "Strength" and ownsgamepass(player.UserId, strengthPass))
		or (stat == "Endurance" and ownsgamepass(player.UserId, endPass)) then
		value *= 2
	end
	if stat.ClassName ~= "StringValue" and type(value)~='number' then
		warn("value is not number. the value is", value, "the stat is", stat)
	end
	if op == "+" then
		if owns then
			player:WaitForChild(stat).Value += value * 2
		else
			player:WaitForChild(stat).Value += value
		end
	elseif op == "set" then
		if typeof(value)=="number" and owns and not stat:match("Multi") then
			--print(value)
			player:WaitForChild(stat).Value = value * 2
		else
			player:WaitForChild(stat).Value = value
		end
		if val:match("Class") then
			alertClients:FireAllClients(player.Name.." has ranked up to "..value.."!") -- doesn't need player to send to
		end
	end
end)

try that on the server side, see if the error shows.

10:04:28.185 Players.Lamino961.PlayerGui.ServerMessagge:5: attempt to concatenate string with nil - Client - ServerMessagge:5

when I buy a class I get an error by the way here it is

server message script

local event = game.ReplicatedStorage.ServerMessage

event.OnClientEvent:Connect(function(player, msg)
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
		Text = "[SERVER] "..msg;
		Font = Enum.Font.ArialBold;
		Color = Color3.fromRGB(255,94,0);
		FontSize = Enum.FontSize.Size60;
	})
end)

Ok, try this:

local event = game.ReplicatedStorage.ServerMessage

event.OnClientEvent:Connect(function(player, msg)
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
		Text = "[SERVER] "..tostring(msg);
		Font = Enum.Font.ArialBold;
		Color = Color3.fromRGB(255,94,0);
		FontSize = Enum.FontSize.Size60;
	})
end)

if it says stuff like “nil”, then there is a problem

Screenshot_1

That’s a problem. I think it was because it’s on the client so player is not necessary.

local event = game.ReplicatedStorage.ServerMessage

event.OnClientEvent:Connect(function(msg)
	game.StarterGui:SetCore("ChatMakeSystemMessage", {
		Text = "[SERVER] "..tostring(msg);
		Font = Enum.Font.ArialBold;
		Color = Color3.fromRGB(255,94,0);
		FontSize = Enum.FontSize.Size60;
	})
end)

Try this one.

it works thank you, let’s do classes right now, that is, just buying it and not choosing which one is needed

Ok, is the class buying system partially created? If so, what are the functions?

my player chooses which class to buy, and I want when the player just clicks on the purchase without choosing which class he needs

here’s how in this video

It should be the same as the local script from the GUI, except when the player clicks a button and selects the class, it uses that one.

Just these lines

will you help yes do it I just really want to do it

I am confused. Which kind is different from buying the class from the GUI? I thought that one was already finished.

I have it ready, the player chooses which class he buys, and there he just clicks on the button and the class is automatically bought from him

Ok. I understand this.

Is there any current error or issue preventing the solution to the automatic purchase?

I want to do how to rebirth you buy just by clicking on a button this is an example

If there was a mistake, I would warn you, I have no mistakes.

Okay, it’s good that there are no mistakes. So, it’s like the rebirth button but it says that the player can change the class after purchasing it?

How is the game supposed to know which class the player wants to purchase if there is only one button?

For example, I said this so that you would understand what I mean