Should the client know what class they're playing as?

Hello, I’m working on a class fighting game and I’m doing class selection at the moment and I wanted to know if the class the player is playing should be stored on the client?

Currently, my code when the player touches a part it asks the server if it can play as that class and after sanity checks if the player can in-fact be that class the client will add the class module to them which just stores functions for abilities that the input code uses.

for _,part in ipairs(CollectionService:GetTagged("ClassSelector")) do
	part.Touched:Connect(function(part)
		local touchedModel = part:FindFirstAncestorWhichIsA("Model")
		if not touchedModel then return end
		
		local player = Players:GetPlayerFromCharacter(touchedModel)
		if not player then return end
		
		if player ~= Players.LocalPlayer then return end
		
		print("Hey server! I wanna play as this class :)")
		ClassSelected:FireServer()		
	end)
end
ClassSelected.OnServerEvent:Connect(function(player)
	-- Eventually, add sanity checks
	print("Ok client you can play as this class")
	ClassSelected:FireClient(player,"TestClass")
end)
function Player.new()
	local self = setmetatable({},Player)
	
	self.Class = nil
	self.Input = Input.new(self)
	
	ClassSelected.OnClientEvent:Connect(function(class)
		self:SetClass(class)
	end)
	
	return self
end

function Player:SetClass(className)
	if not className then return end

	if Classes:FindFirstChild(className) then
		local classModule = require(Classes[className])
		self.Class = classModule.new()
	end
end

The player should know what class they are playing as. However, for security reasons, class abilities should be on the server only. When the client uses a class ability, it should send a message to the server via a remote event and the server performs the action. By having this code on the client, a cheater can take advantage of this and use abilities that do not belong to their current class.

2 Likes