Provide an overview of:
- What does the code do and what are you not satisfied with?
What I am not satisfied with is that the touch event only works for 1 NPC at a time-the first one that
touches the part.
Basically 6000 thousands of lines of code plus some more which is all repeated, to achieve for one a
up and down movement and a part touch detector for a specific NPC.
- What potential improvements have you considered?
I looked through all the Dev forum pages that had relative problems but none had the answer I was
trying to achieve
- How (specifically) do you want to improve the code?
Putting it frankly I don’t want 120 parts going up and down every 1.5 seconds, it creates lag.
So how about just 1 part that detects all the NPCS
I DONT THINK PROVIDING THE CODE IS NECCECARRY BUT HERE:
DETECTOR CODE: (* 120)
flagcapture1.Touched:Connect(function (part)
local humanoid1 = part.Parent:FindFirstChild("Humanoidr2")
if humanoid1 then
flagcapture1.CanTouch = false
if teamBlue == 0 and teamGreen == 0 and teamBlack == 0 then
if teamRed < 100 then
teamRed += 1
end
else
if teamBlue > 0 then
teamBlue -= 1
elseif teamGreen > 0 then
teamGreen -= 1
elseif teamBlack > 0 then
teamBlack -= 1
end
end
end
wait(1)
flagcapture1.CanTouch = true
end)
UP AND DOWN CODE:(* 120)
local part = script.Parent
local deb = false
while true do
if deb == false then
deb = true
wait(1)
part.Position += Vector3.new(0,5,0)
wait(0.5)
part.Position -= Vector3.new(0,5,0)
deb = false
end
wait()
end