#help on class system
47 messages · Page 1 of 1 (latest)
When you say class you're talking about teaching class or the data type ?
like a class like in a mmorpg like world of warcraft
Oh ok
thats what i mean
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
For your isWarrior function you can just do
local function isWarrior(player)
return player:FindFirstChild("Warrior")
end
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
Now this is your tool script but for assignation of your class you should do an enum of your class type
Np
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
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
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)
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
}
Tbh Idk about the MMORPG stuff
So for me races and classes are the same
It was just for you to get the idea
yeah not everyone players them, races are different from class it i understand what you mean
yeah i understand i think
thank you
Don't hardcode it
hardcore?
Np
No hardcode which is basically scripting every cases
But I doubt you coded this by your own did you ?
yes bro i use chatgpt then i went back and try learning how this worked
which now i understand how it works
mostly
And did you figured out how it works ?
So you can rescript everything without watching at it ?
no i still need to learn a bit more then maybe