I’m using OOP to make guns and my question is should Gun.new
handled on the client or server?
If you are going for OOP you will need both on client and server as Gun has aspects that are different client and server.
GunObjectClient
→ GunEffects
–>GunInput
–>BulletSimulation
GunObjectServer
–>GunHitDetection
–>BulletSimulation
–>DamageSystem
Also go for components instead of inheritance, By this I mean, building objects with objects like so:
local function GunClient.new()
gun = GunEffects.new()
end
So the code is modular and you can move it around if you don’t like the organization and such, or want to rework the system.
Don’t like gun effects on the client? Just remove all related to GunEffects object.
local function GunClient.new()
--gun = GunEffects.new()
end
--add it to gun server instead
local function GunServer.new()
gun = GunEffects.new()
end
Also consider other code paradigm like ECS, or maybe just functional programming. Signals also help for organizing things like effects related to gun fire. (BindableEvents can also act as signals)
local function fireGun()
signal:Fire()--let other scripts know the gun is fired to do effects and stuff.
end