How to make? class system

Hello, I have scripts, but I can’t use them as in the video, I want when a local player presses a button, he is given a different class, I have scripts, help me do

10 Likes

I want to make it so that when a local player presses the blue button, he has a different class, how to do? I have scripts

2 Likes

guys, why don’t I say write a script, but I say help me with mine, I have scripts

1 Like

Your translator is kinda messing it up. Can you send the local script that handles the buttons and the server script that is in charge of the buttons click event?

1 Like

ok now I’ll send it wait Right now I’ll go to the studio

1 Like

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

script.Parent.MouseButton1Click:Connect(function()
if name.Text == “D-Class” and class.Value ~= “D-Class” then
if tp.Value >= 50 then
setClass:FireServer(“Class”, “D-Class”, “set”)
reset:FireServer()
end
end
end)

4 Likes

this is a button when a local player clicks on a button and buys a class

1 Like

Screenshot_1

This script works fine.

Can you show me the server scripts that connects to these RemoteEvents?

1 Like

I want the player not to choose which class to buy and when he clicks on the button it is bought automatically as in the screenshot that I threw off

1 Like

No, I mean I want to see the server scripts that has OnServerEvent on the Remotes you are firing with the script, which works fine with no errors.

you mean the ones that are in the server store, I just don’t understand you

I think you mean this

local func = game:GetService("ReplicatedStorage").RemoteFunctions.RetrieveClassMult

  func.OnServerInvoke = function(player)
local class = player.Class
local mults = require(game.ServerStorage["classMults"])

local classMult
if class.Value == "F-Class" then
	classMult = mults.fClass
elseif  class.Value == "D-Class" then
	classMult = mults.dClass
end

return classMult

end

Might be useful but that’s not exactly what I need. Show the game.ReplicatedStorage.AddStat.OnServerEvent:Connect and game.ReplicatedStorage.ResetStats.OnServerEvent:Connect functions

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 function ownsgamepass(userId, gamepassId)
	local s,res = pcall(MarketPlaceService.UserOwnsGamePassAsync, MarketPlaceService, userId, gamepassId)
	if not s then
		res = false
	end
	return res
end

event.OnServerEvent:Connect(function(player, stat, val, op)
	local owns = ownsgamepass(player.UserId, gamepassId)
	if stat == "Strength" and ownsgamepass(player.UserId, strengthPass) 
		or stat == "Endurance" and ownsgamepass(player.UserId, endPass) then
		val = val*2
	end
	if op == "+" then
	if owns then
		player:WaitForChild(stat).Value += val*2
    else
		player:WaitForChild(stat).Value += val
	end
	elseif op == "set" then
	if owns and not stat:match("Multi") then
		player:WaitForChild(stat).Value = val*2
	else
		player:WaitForChild(stat).Value = val
	end
	if val:match("Class") then
		alertClients:FireAllClients(player, player.Name.." has ranked up to "..val.."!")
		end
	end
end)
1 Like

reset stat


event.OnServerEvent:Connect(function(player)
	player.Strength.Value = 0
	player.Psp.Value = 0
	player.Endurance.Value = 0
end)

put three backticks for the code next time

It’s like tell me I’m just a beginner

image
what is val2?

you spelled it wrong, it should have been a gamepass indicator.