so i went on a search to find out what is efficient coding and bascially the summary is less steps the code take to do something the better it will run
which i got another question. how do you know if its efficient code if you dont know how to read what steps the code is taking?
the only problem is i do not know how to read steps but i know what they do but dont actually know how many steps they take to do
imma just show you how i usually identfie steps of the code taken below so you get how clueless i am
local RemoteEvent = game.ReplicatedStorage.RemoteEvent1
local REMOTEEVENT = game.ReplicatedStorage.RemoteEvent2
local True = true local False = false
RemoteEvent.OnServerEvent:Connect(function() local Model = workspace.model
if False == false then
while True do
Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame()*CFrame.fromEulerAnglesXYZ(0,0.025,0))
wait()
end
False = true
else
while True do
Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame()*CFrame.fromEulerAnglesXYZ(0,-0.025,0))
wait()
end
False = false
end
end)
REMOTEEVENT.OnServerEvent:Connect(function()
True = false
wait()
True = true
end)
line 4 is one step by itself
all ifs cost one step each as well as then
all whiles cost one step each as well as dos
all ends also cost one step each
changing bool values cost one step each
all wait() cost one step each
line 8 and 14 cost two steps in total
line 21 and 12 cost two step in total
in total i counted 26 steps this script is taking to do what it needs to do
i know people in the devforum given example of how to actually count them but the thing is i cant understand it at all because the code i usually write is very different from whats written in their example and i tried to find another example but it was just that same example rephrased with little to no changes or in the worst case which is most likely the most common case for me
i cant find any at all and thats why i went on here. efficient coding was always kinda confusing for me so there might be some stuff said that might be wrong

5 comments
i use runservice.stepped to loop my stuff now
even tho you gave me some good tips i tried fireallclient and i realize a few issues with it after using it for an entire two days
first if another player joins in the heat of a battle then the turrets wont be rotated in the right position and what if a player loses connection and joins again to play with their friend?
second its just bad for what i want it to do
What people usually do is store the CFrame value of the turret on the server, and send that value to the client and have the client portray the movement and do the tweens.