OOP question about sword

I have a question about OOP. Lets say i want to make a sword class and i have added all the necessary coding to make it work. If i want to make the sword work should i do like this? Is this the correct way of making it. It seems weird to create a newsword everytime the player uses their weapon!

tool.Activated:Connect(function())
local NewSword = Sword.new()
NewSword:Damage()
end)
1 Like

here before Yarik tells you to use ECS instead of OOP

3 Likes

Bruh thought you were gonna tell him how to fix it : /. Anyways you should be making the class outside the function and calling the take damage function inside the activation

local newSword = Sword.new()

tool.Activated:Connect(function()
 newSword:Damage()
end)

1 Like

Yeah that makes sense. Appreciate your reply! Thanks for helping me!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.