Not sure if this would be classed as the right category for this. If it’s not let me know and I will change it.
So I am working on a game, currently working on making the weapons, I am using Knit and RaycastHitboxV4
I currently have 1 server script and 3 folders; Components, Modules, and Services. Now I didn’t know whether the weapons would be classed as a Service or Components. I ended up putting it into components since it will apply stats and connections to the swords as they are added.
Weapons Component Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Knit = require(ReplicatedStorage:WaitForChild("Common"):WaitForChild("Knit"))
local Janitor = require(Knit.Util.Janitor)
local RaycastHitbox = require(ReplicatedStorage:WaitForChild("Common"):WaitForChild("RaycastHitboxV4"))
local DataValues = require(script.Parent.Parent:WaitForChild("Module"):WaitForChild("DataValues"))
local Weapons = {}
Weapons.__index = Weapons
Weapons.Tag = "Weapon"
function Weapons.new(instance)
local self = setmetatable({}, Weapons)
self._janitor = Janitor.new()
self.Stats = DataValues[instance.Name]
local newHitbox = RaycastHitbox.new(instance)
self.Connections = {
["Attack"] = instance.Activated:Connect(function()
print("Used "..instance.Name)
newHitbox.OnHit:Connect(function(hit, humanoid)
print(hit.Name)
humanoid:TakeDamage(self.Stats.Damage)
end)
newHitbox:HitStart()
end)
}
self._janitor:Add(function()
print("Weapon Destroyed")
end)
return self
end
function Weapons:Init()
end
function Weapons:Deinit()
end
function Weapons:Destroy()
self._janitor:Cleanup()
end
return Weapons
My questions are:
Would it be bad to run all of this on the server (including the animations, sound, damage)?
Are there any bad practices/ lines of code?
–
Thank you and I feel like this post will get mixed reactions since it’s not a problem just a bit of guidance. I appreciate everyone that has read this, this is my first project using Knit and other APIs.