#help on class system

47 messages · Page 1 of 1 (latest)

manic harness
#

I got it where you can select a class but i do not got it so that your class determains on which tools you can use any help? Using a Table

dense snow
manic harness
#

like a class like in a mmorpg like world of warcraft

dense snow
#

Oh ok

dense snow
#

So for example elf = bow tool

#

And stuff like that

manic harness
#

kinda like this code here

-- Get the player
local player = game.Players.LocalPlayer -- Assuming this is a local script, change if necessary

-- Get the tool (assuming the script is inside the tool)
local tool = script.Parent

-- Function to check if player is a warrior
local function isWarrior(player)
if player:FindFirstChild("Warrior") then
return true
else
return false
end
end

-- Function to handle tool usage
local function useTool()
if isWarrior(player) then
-- Allow the player to use the tool
print("You are a warrior! You can use the tool.")
-- Put your tool usage code here
else
-- Do not allow the player to use the tool
print("You are not a warrior. You cannot use the tool.")
end
end

-- Connect tool activation to useTool function
tool.Activated:Connect(useTool)

#

its by the players class

#

i just want to know how to make it simpler by adding it in a table

dense snow
manic harness
#

oh you can

#

how do you make it in the discord server just change the text to a code text like you did were you can copy?

#

um using this will not work when you are a warrior

local function isWarrior(player)
return player:FindFirstChild("Warrior")
end

manic harness
#
print("hello")
#

oh it does

#

thats cool

#

thanks

dense snow
dense snow
manic harness
#

well the way the system works is when you click a class it adds a value you your player called Warrior, Archer, Rogue and if you have that in your player then depending on the weapon then it will work

dense snow
#

This is how to do it

_G.ClassEnum = {
  WARRIOR,
  TROLL,
  ELF,
  WIZZARD
}

And then access those data elements by simply doing

ClassEnum.WIZZARD

And now you can create your number value that have as value the ClassEnum for your type

-- in server script 

local classType = player: FindFirstChild("ClassType") or assert(Instance.new("NumberValue", player))
classType.Value = ClassEnum.TROLL
manic harness
#

how is yours working yours is kinda confusing becuase trolls and elfs are races not classes and how are you getting an number value becuase mine adds it to the player

#

using this

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local SendClassWarrior = ReplicatedStorage:WaitForChild("SendClassWarrior")

local SendClassArcher = ReplicatedStorage:WaitForChild("SendClassArcher")

local SendClassRogue = ReplicatedStorage:WaitForChild("SendClassRogue")

SendClassWarrior.OnServerEvent:Connect(function(Player)
local CloneWarrior = script.Warrior:Clone()
CloneWarrior.Parent = Player
end)

SendClassArcher.OnServerEvent:Connect(function(Player)
local CloneArcher = script.Archer:Clone()
CloneArcher.Parent = Player
end)

SendClassRogue.OnServerEvent:Connect(function(Player)
local CloneRogue = script.Rogue:Clone()
CloneRogue.Parent = Player
end)

dense snow
#

For the weapon thingy you can do something interesting using your enums by setting them in a table with the tools

local tools = {
  [ClassEnum.TROLL] = stickTool
}
dense snow
#

So for me races and classes are the same

#

It was just for you to get the idea

manic harness
#

yeah not everyone players them, races are different from class it i understand what you mean

#

yeah i understand i think

#

thank you

manic harness
#

hardcore?

dense snow
dense snow
#

But I doubt you coded this by your own did you ?

manic harness
#

yes bro i use chatgpt then i went back and try learning how this worked

#

which now i understand how it works

#

mostly

dense snow
#

And did you figured out how it works ?

manic harness
#

yes

#

mostly

dense snow
manic harness
#

no i still need to learn a bit more then maybe

dense snow
#

Alr

#

Well good luck by learning