Provide an overview of:
- What does the code do and what are you not satisfied with?
My code checks if my mouse, while holding a tool, is pointed at a specific part. If it is, then it fires a server event on click. - What potential improvements have you considered?
I have considered using a table/array (I am not sure which is which or much about each yet to use one in this script). - How (specifically) do you want to improve the code?
I simply want to make it shorter. I saw a post of someone replacing a lot of if and elseif statements with a table and made me consider doing it for my own script.
function onButton1Down(player)
if mouse.Target == ComicPlacement1 then
CopyComic7P1:FireServer()
print("Copying Comic7 to Placement1")
elseif mouse.Target == ComicPlacement2 then
CopyComic7P2:FireServer()
print("Copying Comic7 to Placement2")
elseif mouse.Target == ComicPlacement3 then
CopyComic7P3:FireServer()
print("Copying Comic7 to Placement3")
elseif mouse.Target == ComicPlacement4 then
CopyComic7P4:FireServer()
print("Copying Comic7 to Placement4")
elseif mouse.Target == ComicPlacement5 then
CopyComic7P5:FireServer()
print("Copying Comic7 to Placement5")
elseif mouse.Target == ComicPlacement6 then
CopyComic7P6:FireServer()
print("Copying Comic7 to Placement6")
elseif mouse.Target == ComicPlacement7 then
CopyComic7P7:FireServer()
print("Copying Comic7 to Placement7")
elseif mouse.Target == ComicPlacement8 then
CopyComic7P8:FireServer()
print("Copying Comic7 to Placement8")
elseif mouse.Target == ComicPlacement9 then
CopyComic7P9:FireServer()
print("Copying Comic7 to Placement9")
elseif mouse.Target == ComicPlacement10 then
CopyComic7P10:FireServer()
print("Copying Comic7 to Placement10")
elseif mouse.Target == ComicPlacement11 then
CopyComic7P11:FireServer()
print("Copying Comic7 to Placement11")
elseif mouse.Target == ComicPlacement12 then
CopyComic7P2:FireServer()
print("Copying Comic7 to Placement12")
elseif mouse.Target == ComicPlacement13 then
CopyComic7P3:FireServer()
print("Copying Comic7 to Placement13")
elseif mouse.Target == ComicPlacement14 then
CopyComic7P4:FireServer()
print("Copying Comic7 to Placement14")
elseif mouse.Target == ComicPlacement15 then
CopyComic7P5:FireServer()
print("Copying Comic7 to Placement15")
elseif mouse.Target == ComicPlacement16 then
CopyComic7P6:FireServer()
print("Copying Comic7 to Placement16")
end
end
mouse.Button1Down:Connect(onButton1Down)